private static boolean getProperty(String key, boolean defaultValue) { return Utils.getProperty(Constants.PROJECT_NAME_PREFIX + key, defaultValue); } }
private static int getProperty(String key, int defaultValue) { return Utils.getProperty(Constants.PROJECT_NAME_PREFIX + key, defaultValue); }
private static String getProperty(String key, String defaultValue) { return Utils.getProperty(Constants.PROJECT_NAME_PREFIX + key, defaultValue); }
/** * Get the system property. If the system property is not set, or if a * security exception occurs, the default value is returned. * * @param key the key * @param defaultValue the default value * @return the value */ public static boolean getProperty(String key, boolean defaultValue) { String s = getProperty(key, null); if (s != null) { try { return Boolean.parseBoolean(s); } catch (NumberFormatException e) { // ignore } } return defaultValue; }
/** * Get the system property. If the system property is not set, or if a * security exception occurs, the default value is returned. * * @param key the key * @param defaultValue the default value * @return the value */ public static int getProperty(String key, int defaultValue) { String s = getProperty(key, null); if (s != null) { try { return Integer.decode(s).intValue(); } catch (NumberFormatException e) { // ignore } } return defaultValue; }
/** * Get the setting for the given key. * * @param key the key * @param defaultValue the default value * @return the setting */ protected String get(String key, String defaultValue) { StringBuilder buff = new StringBuilder(Constants.PROJECT_NAME_PREFIX); for (char c : key.toCharArray()) { if (c == '_') { buff.append('.'); } else { // Character.toUpperCase / toLowerCase ignores the locale buff.append(Character.toLowerCase(c)); } } String sysProperty = buff.toString(); String v = settings.get(key); if (v == null) { v = Utils.getProperty(sysProperty, defaultValue); settings.put(key, v); } return v; }
"user.country", "user.language", "user.variant", "file.encoding" }; for (String s : settings) { add(rows, "property." + s, Utils.getProperty(s, ""));