private static String getDatabasePath() { return new File(Utils.getProperty("java.io.tmpdir", "."), SysProperties.PREFIX_TEMP_FILE).getAbsolutePath(); }
/** * 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; }
/** * This method attempts to auto-scale some of our properties to take * advantage of more powerful machines out of the box. We assume that our * default properties are set correctly for approx. 1G of memory, and scale * them up if we have more. */ private static int getAutoScaledForMemoryProperty(String key, int defaultValue) { String s = Utils.getProperty(key, null); if (s != null) { try { return Integer.decode(s).intValue(); } catch (NumberFormatException e) { // ignore } } return Utils.scaleForAvailableMemory(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(); boolean nextUpper = false; for (char c : key.toCharArray()) { if (c == '_') { nextUpper = true; } else { // Character.toUpperCase / toLowerCase ignores the locale buff.append(nextUpper ? Character.toUpperCase(c) : Character.toLowerCase(c)); nextUpper = false; } } String property = buff.toString(); String sysProperty = "ddal." + buff.toString(); String v = settings.get(property); if (v == null) { v = Utils.getProperty(sysProperty, defaultValue); settings.put(property, v); } return v; }
"user.language", "user.variant", "file.encoding" }; for (String s : settings) { add(rows, "property." + s, Utils.getProperty(s, ""));