public class PropertiesUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PropertiesUtils.Property |
| Modifier and Type | Method and Description |
|---|---|
static Map<String,String> |
asMap(Properties properties)
Tired of Properties not behaving like
Map<String,String>s? This method will solve that problem for you. |
static String |
asString(Properties props) |
static void |
checkProperties(Properties properties,
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 Properties |
fromString(String str) |
static <E> E |
get(Properties props,
String key,
E defaultValue,
Type type)
Get the value of a property and automatically cast it to a specific type.
|
static boolean |
getBool(Properties props,
String key)
Load a boolean property.
|
static boolean |
getBool(Properties props,
String key,
boolean defaultValue)
Load a boolean property.
|
static double |
getDouble(Properties props,
String key)
Load a double property.
|
static double |
getDouble(Properties props,
String key,
double defaultValue)
Load a double property.
|
static double[] |
getDoubleArray(Properties props,
String key)
Loads a comma-separated list of doubles from Properties.
|
static int |
getInt(Properties props,
String key)
Load an integer property.
|
static int |
getInt(Properties props,
String key,
int defaultValue)
Load an integer property.
|
static int[] |
getIntArray(Properties props,
String key)
Loads a comma-separated list of integers from Properties.
|
static long |
getLong(Properties props,
String key,
long defaultValue)
Load an integer property as a long.
|
static String |
getSignature(String name,
Properties properties,
PropertiesUtils.Property[] supportedProperties) |
static List<Map.Entry<String,String>> |
getSortedEntries(Properties properties) |
static String |
getString(Properties props,
String key,
String defaultValue)
Load an integer property.
|
static String[] |
getStringArray(Properties props,
String key)
Loads a comma-separated list of strings from Properties.
|
static String[] |
getStringArray(Properties props,
String key,
String[] defaults) |
static boolean |
hasProperty(Properties props,
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(String message,
Properties properties) |
static void |
printProperties(String message,
Properties properties,
PrintStream stream) |
public static boolean hasProperty(Properties props, String key)
props - Properties objectkey - The key to testpublic static String asString(Properties props)
public static Properties fromString(String str)
public static void printProperties(String message, Properties properties, PrintStream stream)
public static void printProperties(String message, Properties properties)
public static Map<String,String> asMap(Properties properties)
Map<String,String>s? This method will solve that problem for you.public static List<Map.Entry<String,String>> getSortedEntries(Properties properties)
public static void checkProperties(Properties properties, 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(Properties props, String key, E defaultValue, Type type)
public static String getString(Properties props, String key, String defaultValue)
public static int getInt(Properties props, String key)
public static int getInt(Properties props, String key, int defaultValue)
public static long getLong(Properties props, String key, long defaultValue)
public static double getDouble(Properties props, String key)
public static double getDouble(Properties props, String key, double defaultValue)
public static boolean getBool(Properties props, String key)
public static boolean getBool(Properties props, String key, boolean defaultValue)
public static int[] getIntArray(Properties props, String key)
public static double[] getDoubleArray(Properties props, String key)
public static String[] getStringArray(Properties props, String key)
public static String[] getStringArray(Properties props, String key, String[] defaults)
public static String getSignature(String name, Properties properties, PropertiesUtils.Property[] supportedProperties)