util
Class Configuration

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--util.Configuration
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class Configuration
extends java.util.Properties

see 'Program Generators using Java and XML' by J. Craig Cleaveland Published in the Prentice-Hall XML series, 2001 chapter 6

changed composition with Properties to inheritance of Properties to conveniently add support for defaults

implemented getList(), added getSlice() TODO: getIntList?

author Thijs Verhagen

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Hashtable
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Fields inherited from class java.util.Hashtable
 
Constructor Summary
Configuration()
           
Configuration(java.util.Properties def)
           
 
Method Summary
 java.lang.String get(java.lang.String key)
           
 boolean get(java.lang.String key, boolean defaultValue)
          evaluates 'true' or 'yes' and 'false' or 'no' (ignore case)
 java.util.Properties getAll()
          return all values; including values set only in defaults
 int getInt(java.lang.String key, int defaultValue)
           
 java.util.Vector getKeys(java.lang.String prefix, java.lang.String suffix)
          Gets all keys with a given prefix and suffix
 java.lang.String[] getList(java.lang.String key)
          Get the value as a list of strings (separated by ';')
 java.util.Properties getSlice(java.lang.String prefix, java.lang.String suffix)
          return property with all key/values with key with given prefix and suffix
 java.util.Iterator getSliceIt(java.lang.String prefix, java.lang.String suffix)
           
 java.lang.String getStrict(java.lang.String key)
          return value if key is
 void loadFromCP(java.lang.String fn)
          use class-loader to search for fn
static java.lang.String[] parseColonSeparatedList(java.lang.String v)
           
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()

Configuration

public Configuration(java.util.Properties def)
Method Detail

loadFromCP

public void loadFromCP(java.lang.String fn)
                throws java.io.IOException
use class-loader to search for fn

java.io.IOException

get

public java.lang.String get(java.lang.String key)
Returns:
String val or null

getStrict

public java.lang.String getStrict(java.lang.String key)
return value if key is

Returns:
String val or empty string

get

public boolean get(java.lang.String key,
                   boolean defaultValue)
evaluates 'true' or 'yes' and 'false' or 'no' (ignore case)

Returns:
boolean

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Returns:
int value or default value if property cannot be parsed

getKeys

public java.util.Vector getKeys(java.lang.String prefix,
                                java.lang.String suffix)
Gets all keys with a given prefix and suffix


getSlice

public java.util.Properties getSlice(java.lang.String prefix,
                                     java.lang.String suffix)
return property with all key/values with key with given prefix and suffix

See Also:
getKeys(java.lang.String, java.lang.String)

getSliceIt

public java.util.Iterator getSliceIt(java.lang.String prefix,
                                     java.lang.String suffix)

getAll

public java.util.Properties getAll()
return all values; including values set only in defaults

See Also:
Properties.defaults

getList

public java.lang.String[] getList(java.lang.String key)
Get the value as a list of strings (separated by ';')


parseColonSeparatedList

public static java.lang.String[] parseColonSeparatedList(java.lang.String v)
Returns:
null if v is empty or null