|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.shared.ldap.util.PropertiesUtils
A utility class used for accessing, finding, merging and macro expanding properties, on disk, via URLS or as resources.
Constructor Summary | |
PropertiesUtils()
|
Method Summary | |
static void |
discover(java.util.Properties keys,
java.util.Properties[] sources,
boolean haltOnDiscovery)
Merges a set of properties from source Properties into a target properties instance containing keys. |
static java.lang.String |
discover(java.lang.String key,
java.util.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 java.util.List |
fill(java.util.Properties props,
java.lang.String key,
java.util.List values)
Fills a list with the space delimited values of a property. |
static java.util.List |
fill(java.util.Properties props,
java.lang.String key,
java.util.List values,
java.lang.String delimiter)
Fills a list with the space delimited values of a property. |
static java.util.Set |
fill(java.util.Properties props,
java.lang.String key,
java.util.Set values)
Fills a set with the space delimited values of a property. |
static java.util.Set |
fill(java.util.Properties props,
java.lang.String key,
java.util.Set values,
java.lang.String delimiter)
Fills a set with the delimited values of a property. |
static javax.naming.directory.Attributes |
fillAttributes(java.util.Properties props,
java.lang.String key,
javax.naming.directory.Attributes values)
Creates, fills and returns an Attributes instance using the LDIF encoded within the property value. |
static java.util.Collection |
fillCollection(java.util.Properties props,
java.lang.String key,
java.util.Collection values,
java.lang.String delimiter)
Fills a collection with the delimited values of a property. |
static java.util.Properties |
findProperties(java.io.File dir,
java.lang.String filename)
Create a new properties object and load the properties file if it exists relative to [dir]/[filename] or [dir]/[filename].properties. |
static java.util.Properties |
findUserProperties(java.lang.String filename)
Loads a properties object in a properties file if it exists relative to the filename ${user.home}. |
static int |
get(java.util.Hashtable ht,
java.lang.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(java.util.Properties props,
java.lang.String key,
boolean defaultValue)
Gets a String property as a boolean returning a defualt if the key is not present. |
static byte |
get(java.util.Properties props,
java.lang.String key,
byte defaultValue)
|
static char |
get(java.util.Properties props,
java.lang.String key,
char defaultValue)
|
static long |
get(java.util.Properties props,
java.lang.String key,
long defaultValue)
|
static java.util.Properties |
getProperties(java.lang.ClassLoader classloader,
java.lang.String path)
Loads a properties file as a CL resource if it exists and returns an empty Properties object otherwise. |
static java.util.Properties |
getProperties(java.lang.Class clazz,
java.lang.String path)
Loads a properties file as a class resource if it exists and returns an empty Properties object otherwise. |
static java.util.Properties |
getProperties(java.io.File file)
Creates a properties object and loads the properties in the file otherwise and empty property object will be returned. |
static java.util.Properties |
getStaticProperties(java.lang.Class ref)
Load a properties from a resource relative to a supplied class. |
static java.util.Properties |
getStaticProperties(java.lang.Class ref,
java.lang.String path)
Load properties from a resource relative to a supplied class and path. |
static void |
macroExpand(java.util.Properties expanded,
java.util.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 |
Constructor Detail |
public PropertiesUtils()
Method Detail |
public static java.util.Properties findUserProperties(java.lang.String filename)
filename
- the properties file name with or without an extension
public static java.util.Properties findProperties(java.io.File dir, java.lang.String filename)
dir
- the base directoryfilename
- the full fine name or the base name w/o the extension
public static java.util.Properties getStaticProperties(java.lang.Class ref)
ref
- a class to use for relative path references
public static java.util.Properties getStaticProperties(java.lang.Class ref, java.lang.String path)
ref
- a class to use for relative path referencespath
- the relative path to the resoruce
public static java.util.Properties getProperties(java.io.File file)
file
- the properties file
public static java.util.Properties getProperties(java.lang.ClassLoader classloader, java.lang.String path)
classloader
- the loader to use for the resourcespath
- the path to the resource
public static java.util.Properties getProperties(java.lang.Class clazz, java.lang.String path)
clazz
- the class to use for resolving the resourcespath
- the relative path to the resource
public static void macroExpand(java.util.Properties expanded, java.util.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 java.lang.String discover(java.lang.String key, java.util.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(java.util.Properties keys, java.util.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 findpublic static boolean get(java.util.Properties props, java.lang.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(java.util.Hashtable ht, java.lang.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(java.util.Properties props, java.lang.String key, long defaultValue)
public static byte get(java.util.Properties props, java.lang.String key, byte defaultValue)
public static char get(java.util.Properties props, java.lang.String key, char defaultValue)
public static java.util.Set fill(java.util.Properties props, java.lang.String key, java.util.Set values)
props
- the properties to get the property values fromkey
- the key of the multivalued propertyvalues
- the values to populate
public static java.util.Set fill(java.util.Properties props, java.lang.String key, java.util.Set values, java.lang.String delimiter)
props
- the properties to get the property values fromkey
- the key of the multivalued propertyvalues
- the values to populatedelimiter
- the delimiter string to split the property with
public static java.util.List fill(java.util.Properties props, java.lang.String key, java.util.List values)
props
- the properties to get the property values fromkey
- the key of the multivalued propertyvalues
- the values to populate
public static java.util.List fill(java.util.Properties props, java.lang.String key, java.util.List values, java.lang.String delimiter)
props
- the properties to get the property values fromkey
- the key of the multivalued propertyvalues
- the values to populatedelimiter
- the delimiter string to split the property with
public static java.util.Collection fillCollection(java.util.Properties props, java.lang.String key, java.util.Collection values, java.lang.String delimiter)
props
- the properties to get the property values fromkey
- the key of the multivalued propertyvalues
- the values to populatedelimiter
- the delimiter string to split the property with
public static javax.naming.directory.Attributes fillAttributes(java.util.Properties props, java.lang.String key, javax.naming.directory.Attributes values) throws javax.naming.NamingException
props
- the properties to get the ldif property fromkey
- the key for the LDIF property
javax.naming.NamingException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |