|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.shared.util.PropertiesUtils
public final class PropertiesUtils
A utility class used for accessing, finding, merging and macro expanding properties, on disk, via URLS or as resources.
| Method Summary | |
|---|---|
static void |
discover(Properties keys,
Properties[] sources,
boolean haltOnDiscovery)
Merges a set of properties from source Properties into a target properties instance containing keys. |
static String |
discover(String key,
Properties[] sources,
boolean haltOnDiscovery)
Discovers a value within a set of Properties either halting on the first time the property is discovered or continuing on to take the last value found for the property key. |
static Properties |
findProperties(File dir,
String filename)
Create a new properties object and load the properties file if it exists relative to [dir]/[filename] or [dir]/[filename].properties. |
static Properties |
findUserProperties(String filename)
Loads a properties object in a properties file if it exists relative to the filename ${user.home}. |
static int |
get(Hashtable<String,Object> ht,
Object key,
int defval)
Gets a property or entry value from a hashtable and tries to transform whatever the value may be to an primitive integer. |
static boolean |
get(Properties props,
String key,
boolean defaultValue)
Gets a String property as a boolean returning a defualt if the key is not present. |
static byte |
get(Properties props,
String key,
byte defaultValue)
|
static char |
get(Properties props,
String key,
char defaultValue)
|
static long |
get(Properties props,
String key,
long defaultValue)
|
static Properties |
getProperties(Class<?> clazz,
String path)
Loads a properties file as a class resource if it exists and returns an empty Properties object otherwise. |
static Properties |
getProperties(ClassLoader classloader,
String path)
Loads a properties file as a CL resource if it exists and returns an empty Properties object otherwise. |
static Properties |
getProperties(File file)
Creates a properties object and loads the properties in the file otherwise and empty property object will be returned. |
static Properties |
getStaticProperties(Class<?> ref)
Load a properties from a resource relative to a supplied class. |
static Properties |
getStaticProperties(Class<?> ref,
String path)
Load properties from a resource relative to a supplied class and path. |
static void |
macroExpand(Properties expanded,
Properties[] optionals)
Expands out a set of property key macros in the following format ${foo.bar} where foo.bar is a property key, by dereferencing the value of the key using the original source Properties and other optional Properties. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Properties findUserProperties(String filename)
filename - the properties file name with or without an extension
public static Properties findProperties(File dir,
String filename)
dir - the base directoryfilename - the full fine name or the base name w/o the extension
public static Properties getStaticProperties(Class<?> ref)
ref - a class to use for relative path references
public static Properties getStaticProperties(Class<?> ref,
String path)
ref - a class to use for relative path referencespath - the relative path to the resoruce
public static Properties getProperties(File file)
file - the properties file
public static Properties getProperties(ClassLoader classloader,
String path)
classloader - the loader to use for the resourcespath - the path to the resource
public static Properties getProperties(Class<?> clazz,
String path)
clazz - the class to use for resolving the resourcespath - the relative path to the resource
public static void macroExpand(Properties expanded,
Properties[] optionals)
expanded - the Properties to perform the macro expansion uponoptionals - null or an optional set of Properties to use for dereferencing
macro keys (foo.bar)
public static String discover(String key,
Properties[] sources,
boolean haltOnDiscovery)
key - a property keysources - a set of source PropertieshaltOnDiscovery - true if we stop on finding a value, false otherwise
public static void discover(Properties keys,
Properties[] sources,
boolean haltOnDiscovery)
keys - the keys to discover values forsources - the sources to searchhaltOnDiscovery - true to halt on first find or false to continue to last find
public static boolean get(Properties props,
String key,
boolean defaultValue)
props - the properties to get the value fromkey - the property keydefaultValue - the default value to return if key is not present
public static int get(Hashtable<String,Object> ht,
Object key,
int defval)
ht - the hashtable to access for the valuekey - the key to use when accessing the htdefval - the default value to use if the key is not contained in ht or
if the value cannot be represented as a primitive integer.
public static long get(Properties props,
String key,
long defaultValue)
public static byte get(Properties props,
String key,
byte defaultValue)
public static char get(Properties props,
String key,
char defaultValue)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||