/** * Remove a String property if it is set and return the value. * * @param key the property name * @param defaultValue the default value * @return the value */ public String removeProperty(String key, String defaultValue) { if (SysProperties.CHECK && !isKnownSetting(key)) { DbException.throwInternalError(key); } Object x = prop.remove(key); return x == null ? defaultValue : x.toString(); }
/** * Get the value of the given property. * * @param key the property key * @param defaultValue the default value * @return the value as a String */ public int getProperty(String key, int defaultValue) { if (SysProperties.CHECK && !isKnownSetting(key)) { DbException.throwInternalError(key); } String s = getProperty(key); return s == null ? defaultValue : Integer.parseInt(s); }
public void addProperty(String key, String value, boolean checkDuplicate) { key = StringUtils.toUpperEnglish(key); if (checkDuplicate) { String old = prop.getProperty(key); if (old != null) { if (!old.equals(value)) { throw DbException.get(ErrorCode.DUPLICATE_PROPERTY_1, key); } return; } } if (isKnownSetting(key)) { prop.put(key, value); } else { throw DbException.get(ErrorCode.UNSUPPORTED_SETTING_1, key); } }
/** * Get the value of the given property. * * @param key the property key * @param defaultValue the default value * @return the value as a String */ public String getProperty(String key, String defaultValue) { if (SysProperties.CHECK && !isKnownSetting(key)) { DbException.throwInternalError(key); } String s = getProperty(key); return s == null ? defaultValue : s; }