/** * Returns the value of the attribute specified by its name as a * <code>String</code>. * * @param name the name of the attribute * @param defaultValue the default value to return if value malformed or empty * @return the value */ public String getAttribute( final String name, final String defaultValue ) { try { return getAttribute( name ); } catch( final ConfigurationException ce ) { return defaultValue; } }
/** * Returns the value of the attribute specified by its name as a * <code>float</code>. * * @param name the name of the attribute * @throws ConfigurationException if an error occurs * @return the value */ public float getAttributeAsFloat( final String name ) throws ConfigurationException { final String value = getAttribute( name ); try { return Float.parseFloat( value ); } catch( final Exception e ) { final String message = "Cannot parse the value \"" + value + "\" as a float in the attribute \"" + name + "\" at " + getLocation(); throw new ConfigurationException( message ); } }
throws ConfigurationException final String value = getAttribute( name ).trim(); try
throws ConfigurationException final String value = getAttribute( name );
/** * Returns the value of the attribute specified by its name as a * <code>double</code>. * * @param name the name of the attribute * @throws ConfigurationException if an error occurs * @return the value */ public double getAttributeAsDouble( final String name ) throws ConfigurationException { final String value = getAttribute( name ); try { return Double.parseDouble( value ); } catch( final Exception e ) { final String message = "Cannot parse the value \"" + value + "\" as a double in the attribute \"" + name + "\" at " + getLocation(); throw new ConfigurationException( message ); } }
/** * Returns the value of the attribute specified by its name as a * <code>boolean</code>. * * @param name the name of the attribute * @throws ConfigurationException if an error occurs * @return the value */ public boolean getAttributeAsBoolean( final String name ) throws ConfigurationException { final String value = getAttribute( name ); if( isTrue( value ) ) { return true; } else if( isFalse( value ) ) { return false; } else { final String message = "Cannot parse the value \"" + value + "\" as a boolean in the attribute \"" + name + "\" at " + getLocation(); throw new ConfigurationException( message ); } }