List of utility methods to do Properties Get
Properties | getLocalizedProperties(String[] propertyKeys, Properties properties) get Localized Properties Properties localizedProperties = new Properties(); for (int i = 0; i < propertyKeys.length; i++) { String key = propertyKeys[i]; if (key != null) { String localizedValue = properties.getProperty(key); if (localizedValue != null) localizedProperties.put(key, localizedValue); return localizedProperties; |
long | getLong(Properties props, String string, long defaultV) get Long if (props.containsKey(string)) { return Long.valueOf(props.getProperty(string)); return defaultV; |
Map | getNestedProperties(String prefix, Properties properties) get Nested Properties Map result = new HashMap(); Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String name = (String) entry.getKey(); String value = (String) entry.getValue(); result.put(prefix + '.' + name, value); return result; |
Object | getProp(Properties props, String name) Get the value of the specified property. Object val = props.get(name); if (val != null) { return val; } else { return props.getProperty(name); |
Map | getPropertiesForBloomFilter(int requiredFieldsSize, int matchKeySize) get Properties For Bloom Filter Map<String, String> properties = new HashMap<String, String>(); double bestIOSortRecordPercent = 16.0 / (16.0 + 8 + requiredFieldsSize + matchKeySize); bestIOSortRecordPercent = Math.max(Math.round(bestIOSortRecordPercent * 100) / 100.0, 0.01); properties.put("io.sort.record.percent", Double.toString(bestIOSortRecordPercent)); return properties; |
Properties | getPropertiesWithPrefix(Properties pro, String prefix) get Properties With Prefix Enumeration en; Properties aux = new Properties(); en = pro.propertyNames(); for (; en.hasMoreElements();) { String nom = (String) en.nextElement(); if (nom.startsWith(prefix)) { aux.setProperty(nom.substring(prefix.length()), pro.getProperty(nom)); return aux; |
String | getProperty(Properties properties, String context, String key, String def) Returns the property with the given key from the given Properties . String property = properties.getProperty(key, def); if (property == null) { String msg = "[{0}] Property {1} is not set, and no default was given!"; msg = MessageFormat.format(msg, context, key); throw new RuntimeException(msg); return property; |
String | getProperty(Properties props, String keyword) get Property String rv = null; if (props != null) { rv = props.getProperty(keyword); if (rv != null) { if (rv.trim().isEmpty()) { rv = ""; } else { rv = ""; return rv; |
String | getProperty(Properties props, String prefix, String key) get Property return props.getProperty((prefix != null) ? prefix + "." + key : key); |
String | getProperty(Properties props, String propertyName) Reads system variable (cmd option) or config file value on fail return System.getProperty(propertyName, props.getProperty(propertyName));
|