/** * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a string if the property is set, otherwise returns the default value. */ public String getStringProperty(String propertyName, String defaultValue) { String stringValue = trim(properties.getProperty(propertyName, defaultValue)); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + stringValue); } return stringValue; }
/** * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a string if the property is set, otherwise returns the default value. */ public String getStringProperty(String propertyName, String defaultValue) { String stringValue = trim(properties.getProperty(propertyName, defaultValue)); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + stringValue); } return stringValue; }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as an int if the property is set, otherwise returns the default value. * @throws NumberFormatException */ public int getIntProperty(String propertyName, int defaultValue) throws NumberFormatException { String intValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + intValue); } return Integer.parseInt(intValue); }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a long if the property is set, otherwise returns the default value. * @throws NumberFormatException */ public long getLongProperty(String propertyName, long defaultValue) throws NumberFormatException { String longValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + longValue); } return Long.parseLong(longValue); }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a long if the property is set, otherwise returns the default value. * @throws NumberFormatException */ public long getLongProperty(String propertyName, long defaultValue) throws NumberFormatException { String longValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + longValue); } return Long.parseLong(longValue); }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as an int if the property is set, otherwise returns the default value. * @throws NumberFormatException */ public int getIntProperty(String propertyName, int defaultValue) throws NumberFormatException { String intValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + intValue); } return Integer.parseInt(intValue); }
/** * Sets or removes a property value. * * @param propertyName * the name of the property to set or remove. * @param propertyValue * a new value for the property. If this value is null, the named property * will be removed. */ public void setProperty(String propertyName, String propertyValue) { if (propertyValue == null) { this.clearProperty(propertyName); } else { this.properties.put(propertyName, trim(propertyValue)); } }
/** * Sets or removes a property value. * * @param propertyName * the name of the property to set or remove. * @param propertyValue * a new value for the property. If this value is null, the named property * will be removed. */ public void setProperty(String propertyName, String propertyValue) { if (propertyValue == null) { this.clearProperty(propertyName); } else { this.properties.put(propertyName, trim(propertyValue)); } }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a boolean if the property is set, otherwise returns the default value. * @throws IllegalArgumentException */ public boolean getBoolProperty(String propertyName, boolean defaultValue) throws IllegalArgumentException { String boolValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + boolValue); } if (String.valueOf(true).equalsIgnoreCase(boolValue)) { return true; } else if (String.valueOf(false).equalsIgnoreCase(boolValue)) { return false; } else { throw new IllegalArgumentException("Boolean value '" + boolValue + "' for jets3t property '" + propertyName + "' must be 'true' or 'false' (case-insensitive)"); } }
/** * Merges properties from another Properties object into this instance. * If a new property already exists, the property value is replaced. * * @param newProperties * the object containing properties that will be merged into this set of properties. * @param propertiesSource * a name for the source of the properties, such as a properties file name or identifier. This * is only used to generate meaningful debug messages when properties are updated, so it is * possible to tell where the updated property value came from. */ public void loadAndReplaceProperties(Properties newProperties, String propertiesSource) { Iterator<Map.Entry<Object, Object>> propsIter = newProperties.entrySet().iterator(); while (propsIter.hasNext()) { Map.Entry<Object, Object> entry = propsIter.next(); String propertyName = (String) entry.getKey(); String propertyValue = (String) entry.getValue(); if (properties.containsKey(propertyName) && !properties.getProperty(propertyName).equals(propertyValue)) { if (log.isDebugEnabled()) { log.debug("Over-riding jets3t property [" + propertyName + "=" + propertyValue + "] with value from properties source " + propertiesSource + ". New value: [" + propertyName + "=" + trim(propertyValue) + "]"); } } properties.put(propertyName, trim(propertyValue)); } loaded = true; }
/** * Merges properties from another Properties object into this instance. * If a new property already exists, the property value is replaced. * * @param newProperties * the object containing properties that will be merged into this set of properties. * @param propertiesSource * a name for the source of the properties, such as a properties file name or identifier. This * is only used to generate meaningful debug messages when properties are updated, so it is * possible to tell where the updated property value came from. */ public void loadAndReplaceProperties(Properties newProperties, String propertiesSource) { Iterator<Map.Entry<Object, Object>> propsIter = newProperties.entrySet().iterator(); while (propsIter.hasNext()) { Map.Entry<Object, Object> entry = propsIter.next(); String propertyName = (String) entry.getKey(); String propertyValue = (String) entry.getValue(); if (properties.containsKey(propertyName) && !properties.getProperty(propertyName).equals(propertyValue)) { if (log.isDebugEnabled()) { log.debug("Over-riding jets3t property [" + propertyName + "=" + propertyValue + "] with value from properties source " + propertiesSource + ". New value: [" + propertyName + "=" + trim(propertyValue) + "]"); } } properties.put(propertyName, trim(propertyValue)); } loaded = true; }
/** * * @param propertyName * the name of the property to look up. * @param defaultValue * value to return if named property is not set. * @return * the named Property value as a boolean if the property is set, otherwise returns the default value. * @throws IllegalArgumentException */ public boolean getBoolProperty(String propertyName, boolean defaultValue) throws IllegalArgumentException { String boolValue = trim(properties.getProperty(propertyName, String.valueOf(defaultValue))); if (log.isDebugEnabled()) { log.debug(propertyName + "=" + boolValue); } if (String.valueOf(true).equalsIgnoreCase(boolValue)) { return true; } else if (String.valueOf(false).equalsIgnoreCase(boolValue)) { return false; } else { throw new IllegalArgumentException("Boolean value '" + boolValue + "' for jets3t property '" + propertyName + "' must be 'true' or 'false' (case-insensitive)"); } }