public class PropertiesUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PropertiesUtils.Property |
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.String> |
asMap(java.util.Properties properties)
Tired of Properties not behaving like
Map<String,String> s? This method will solve that problem for you. |
static java.lang.String |
asString(java.util.Properties props) |
static void |
checkProperties(java.util.Properties properties,
java.util.Properties defaults)
Checks to make sure that all properties specified in
properties
are known to the program by checking that each simply overrides
a default value. |
static java.util.Properties |
fromString(java.lang.String str) |
static <E> E |
get(java.util.Properties props,
java.lang.String key,
E defaultValue,
java.lang.reflect.Type type)
Get the value of a property and automatically cast it to a specific type.
|
static boolean |
getBool(java.util.Properties props,
java.lang.String key)
Load a boolean property.
|
static boolean |
getBool(java.util.Properties props,
java.lang.String key,
boolean defaultValue)
Load a boolean property.
|
static double |
getDouble(java.util.Properties props,
java.lang.String key)
Load a double property.
|
static double |
getDouble(java.util.Properties props,
java.lang.String key,
double defaultValue)
Load a double property.
|
static double[] |
getDoubleArray(java.util.Properties props,
java.lang.String key)
Loads a comma-separated list of doubles from Properties.
|
static int |
getInt(java.util.Properties props,
java.lang.String key)
Load an integer property.
|
static int |
getInt(java.util.Properties props,
java.lang.String key,
int defaultValue)
Load an integer property.
|
static int[] |
getIntArray(java.util.Properties props,
java.lang.String key)
Loads a comma-separated list of integers from Properties.
|
static long |
getLong(java.util.Properties props,
java.lang.String key,
long defaultValue)
Load an integer property as a long.
|
static java.lang.String |
getSignature(java.lang.String name,
java.util.Properties properties,
PropertiesUtils.Property[] supportedProperties) |
static java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getSortedEntries(java.util.Properties properties) |
static java.lang.String[] |
getStringArray(java.util.Properties props,
java.lang.String key)
Loads a comma-separated list of strings from Properties.
|
static java.lang.String[] |
getStringArray(java.util.Properties props,
java.lang.String key,
java.lang.String[] defaults) |
static boolean |
hasProperty(java.util.Properties props,
java.lang.String key)
Returns true iff the given Properties contains a property with the given
key (name), and its value is not "false" or "no" or "off".
|
static void |
printProperties(java.lang.String message,
java.util.Properties properties) |
static void |
printProperties(java.lang.String message,
java.util.Properties properties,
java.io.PrintStream stream) |
public static boolean hasProperty(java.util.Properties props, java.lang.String key)
props
- Properties objectkey
- The key to testpublic static java.lang.String asString(java.util.Properties props)
public static java.util.Properties fromString(java.lang.String str)
public static void printProperties(java.lang.String message, java.util.Properties properties, java.io.PrintStream stream)
public static void printProperties(java.lang.String message, java.util.Properties properties)
public static java.util.Map<java.lang.String,java.lang.String> asMap(java.util.Properties properties)
Map<String,String>
s? This method will solve that problem for you.public static java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> getSortedEntries(java.util.Properties properties)
public static void checkProperties(java.util.Properties properties, java.util.Properties defaults)
properties
are known to the program by checking that each simply overrides
a default value.properties
- Current propertiesdefaults
- Default properties which lists all known keyspublic static <E> E get(java.util.Properties props, java.lang.String key, E defaultValue, java.lang.reflect.Type type)
public static int getInt(java.util.Properties props, java.lang.String key)
public static int getInt(java.util.Properties props, java.lang.String key, int defaultValue)
public static long getLong(java.util.Properties props, java.lang.String key, long defaultValue)
public static double getDouble(java.util.Properties props, java.lang.String key)
public static double getDouble(java.util.Properties props, java.lang.String key, double defaultValue)
public static boolean getBool(java.util.Properties props, java.lang.String key)
public static boolean getBool(java.util.Properties props, java.lang.String key, boolean defaultValue)
public static int[] getIntArray(java.util.Properties props, java.lang.String key)
public static double[] getDoubleArray(java.util.Properties props, java.lang.String key)
public static java.lang.String[] getStringArray(java.util.Properties props, java.lang.String key)
public static java.lang.String[] getStringArray(java.util.Properties props, java.lang.String key, java.lang.String[] defaults)
public static java.lang.String getSignature(java.lang.String name, java.util.Properties properties, PropertiesUtils.Property[] supportedProperties)