net.dpml.util
Class Util

java.lang.Object
  extended by net.dpml.util.Util

public final class Util
extends Object

Utility class supporting operations related to property retrival.

Version:
1.0.3
Author:
Digital Product Meta Library

Method Summary
static String getProperty(Properties props, String key, String def)
          Return the value of a property.
static String[] readListFile(URL listFile)
          Read a file and return the list of lines in an array of strings.
static Properties readProps(URL propsUrl)
          Read a set of properties from a property file specificed by a url.
static Properties readProps(URL propsUrl, boolean resolve)
          Read a set of properties from a property file specificed by a url.
static String resolveProperty(Properties props, String value)
          Resolve symbols in a supplied value against supplied known properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readProps

public static Properties readProps(URL propsUrl)
                            throws IOException
Read a set of properties from a property file specificed by a url. Property files may reference symbolic properties in the form ${name}.

Parameters:
propsUrl - the url of the property file to read
Returns:
the resolved properties
Throws:
IOException - if an io error occurs

readProps

public static Properties readProps(URL propsUrl,
                                   boolean resolve)
                            throws IOException
Read a set of properties from a property file specificed by a url. Property files may reference symbolic properties in the form ${name}.

Parameters:
propsUrl - the url of the property file to read
resolve - if TRUE apply property symbol resolution
Returns:
the resolved properties
Throws:
IOException - if an io error occurs

resolveProperty

public static String resolveProperty(Properties props,
                                     String value)
Resolve symbols in a supplied value against supplied known properties.

Parameters:
props - a set of know properties
value - the string to parse for tokens
Returns:
the resolved string

getProperty

public static String getProperty(Properties props,
                                 String key,
                                 String def)
Return the value of a property.

Parameters:
props - the property file
key - the property key to lookup
def - the default value
Returns:
the resolve value

readListFile

public static String[] readListFile(URL listFile)
                             throws IOException
Read a file and return the list of lines in an array of strings.

Parameters:
listFile - the url to read from
Returns:
the lines
Throws:
IOException - if a read error occurs