/** * Returns the value of the configuration element as a <code>String</code>. * * @param defaultValue the default value to return if value malformed or empty * @return the value */ public String getValue( final String defaultValue ) { try { return getValue(); } catch( final ConfigurationException ce ) { return defaultValue; } }
/** * The toString() operation is used for debugging information. It does * not create a deep reproduction of this configuration and all child configurations, * instead it displays the name, value, and location. * * @return getName() + "::" + getValue() + ":@" + getLocation(); */ public String toString() { return getName() + "::" + getValue("<no value>") + ":@" + getLocation(); } }
throws ConfigurationException final String value = getValue().trim(); try
throws ConfigurationException final String value = getValue().trim(); try
/** * Returns the value of the configuration element as a <code>float</code>. * * @throws ConfigurationException if an error occurs * @return the value */ public float getValueAsFloat() throws ConfigurationException { final String value = getValue().trim(); try { return Float.parseFloat( value ); } catch( final Exception nfe ) { final String message = "Cannot parse the value \"" + value + "\" as a float in the configuration element \"" + getName() + "\" at " + getLocation(); throw new ConfigurationException( message ); } }
/** * Returns the value of the configuration element as a <code>double</code>. * * @throws ConfigurationException if an error occurs * @return the value */ public double getValueAsDouble() throws ConfigurationException { final String value = getValue().trim(); try { return Double.parseDouble( value ); } catch( final Exception nfe ) { final String message = "Cannot parse the value \"" + value + "\" as a double in the configuration element \"" + getName() + "\" at " + getLocation(); throw new ConfigurationException( message ); } }
/** * Returns the value of the configuration element as a <code>boolean</code>. * * @throws ConfigurationException if an error occurs * @return the value */ public boolean getValueAsBoolean() throws ConfigurationException { final String value = getValue().trim(); 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 configuration element \"" + getName() + "\" at " + getLocation(); throw new ConfigurationException( message ); } }