/** * Converts the given String to a boolean value. Accepted values for a * "true" boolean are "1", "on", "yes", "true". Accepted values for a * "false" boolean are "0", "off", "no", "false". * * @param aValue The text value to be tested whether it represents true or * false. * * @return True or false depending on the value passed.n * * @throws IllegalArgumentException in case neither true nor false could be * determined. */ public static boolean toBoolean( String aValue ) throws IllegalArgumentException { for ( String eTrue : Literals.TRUE.getNames() ) { if ( eTrue.equalsIgnoreCase( aValue ) ) { return true; } } for ( String eFalse : Literals.FALSE.getNames() ) { if ( eFalse.equalsIgnoreCase( aValue ) ) { return false; } } throw new IllegalArgumentException( "Unable to determine neither <true> nor <false> for the provided string \"" + aValue + "\"." ); }
/** * Returns the {@link Boolean} value of the property referred to by the key. * As property keys and values are of type {@link String}, the * {@link String} value is converted accordingly. * * @param aKey The key for which to retrieve the value. * * @return The {@link Boolean} representation of the key's {@link String} * value of false if there is no such key. * * @throws NumberFormatException thrown in case conversion fails. */ default Boolean getBoolean( String aKey ) throws NumberFormatException { String theValue = get( aKey ); if ( theValue == null ) { return false; } for ( String eTrue : Literals.TRUE.getNames() ) { if ( eTrue.equalsIgnoreCase( theValue ) ) { return true; } } for ( String eFalse : Literals.FALSE.getNames() ) { if ( eFalse.equalsIgnoreCase( theValue ) ) { return false; } } throw new NumberFormatException( "Unable to parse a Boolean from the String <" + theValue + "> !" ); }
theBooleanArray = new boolean[theArray.length]; next: for ( int i = 0; i < theArray.length; i++ ) { for ( String eTrue : Literals.TRUE.getNames() ) { if ( eTrue.equalsIgnoreCase( theArray[i].trim() ) ) { theBooleanArray[i] = true; for ( String eFalse : Literals.FALSE.getNames() ) { if ( eFalse.equalsIgnoreCase( theArray[i].trim() ) ) { theBooleanArray[i] = false;