fr.tireme.schemadoc.xs2dtd.utils
Class Configuration

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by fr.tireme.schemadoc.xs2dtd.utils.Configuration
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class Configuration
extends java.util.Properties

This class act as the Java Properties class with some added methods such as getInt(),getFloat(),isSelected() and getString(). The order of entry of the key parameters is the order of reading

Author:
niemaz@xrce.xerox.com
See Also:
Serialized Form

Constructor Summary
Configuration()
          Constructor - construct a new Configuration objects with no initial paremeters
Configuration(java.util.Properties defaults)
          Constructor - construct a new Configuration objects with the following parameters
 
Method Summary
 boolean exists(java.lang.String key)
           
 float getFloat(java.lang.String key)
          Get a key value as a float
 int getInt(java.lang.String key)
          get a key value as an int
 long getLong(java.lang.String key)
          Get a key value as a float
 java.lang.String getString(java.lang.String key)
          get a key value as a string.
 java.lang.String getWithAbsolutePath(java.lang.String key, java.lang.String homeDirKey)
          get a key value representing a filename as a string, and make sure that the returned file path is abolute, and not relative. 1st case: the file path starts with a "/" or "X:" -> path is already absolute 2nd case: else, append the filename to the home directory of the application
 boolean isSelected(java.lang.String key)
           
 java.util.Enumeration keys()
          Return the hashtable as an enumeration return Enumeration - the hash enumerate
 void list(java.io.PrintStream out)
          List the hashtable to the specific output
 void list(java.io.PrintWriter out)
          List the hashtable to the specific output
 void loadFromFile(java.lang.String filename)
          Load a file as parameters
 java.util.Enumeration propertyNames()
          get the property names
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Add a new key
 java.lang.Object remove(java.lang.Object key)
          remove a key
 void saveResult(java.io.OutputStream out, java.lang.String header)
          Save the hash to the specific stream
 void saveToFile(java.lang.String filename, java.lang.String header)
          Save to file
 java.lang.String toString()
          Return the hashtable as a string
 
Methods inherited from class java.util.Properties
getProperty, getProperty, load, load, loadFromXML, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, size, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Constructor - construct a new Configuration objects with no initial paremeters


Configuration

public Configuration(java.util.Properties defaults)
Constructor - construct a new Configuration objects with the following parameters

Parameters:
defaults - - the default properties;
Method Detail

loadFromFile

public void loadFromFile(java.lang.String filename)
                  throws java.io.IOException
Load a file as parameters

Parameters:
filename - - the file name to load
Throws:
java.io.IOException

saveToFile

public void saveToFile(java.lang.String filename,
                       java.lang.String header)
                throws java.io.IOException
Save to file

Parameters:
filename - - the file name to save
header - - the file header
Throws:
java.io.IOException

getString

public java.lang.String getString(java.lang.String key)
get a key value as a string. Homogeneous with the other 'get' methods

Parameters:
key - - the wanted key
Returns:
the corresponding string

getInt

public int getInt(java.lang.String key)
get a key value as an int

Parameters:
key - - the wanted key
Returns:
-1 if nothing found

getLong

public long getLong(java.lang.String key)
Get a key value as a float

Parameters:
key - - the wanted key
Returns:
-1 if nothing found

getFloat

public float getFloat(java.lang.String key)
Get a key value as a float

Parameters:
key - - the wanted key
Returns:
-1 if nothing found

getWithAbsolutePath

public java.lang.String getWithAbsolutePath(java.lang.String key,
                                            java.lang.String homeDirKey)
get a key value representing a filename as a string, and make sure that the returned file path is abolute, and not relative. 1st case: the file path starts with a "/" or "X:" -> path is already absolute 2nd case: else, append the filename to the home directory of the application

Parameters:
key - - the wanted key
homeDirKey - the key corresponding to the home directory of the application.
Returns:
the corresponding filename with absolute path

isSelected

public boolean isSelected(java.lang.String key)
Parameters:
key - - the wanted key
Returns:
true if the key was selected (key=on or true), false otherwise

exists

public boolean exists(java.lang.String key)
Parameters:
key - - the wanted exist key
Returns:
true if the key exists (has been initialized and is != '')

remove

public java.lang.Object remove(java.lang.Object key)
remove a key

Specified by:
remove in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
remove in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Parameters:
key - - the key to remove
Returns:
Object - the hash witout the key

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Add a new key

Specified by:
put in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
put in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Parameters:
key - - the key to add
value - the key value

keys

public java.util.Enumeration keys()
Return the hashtable as an enumeration return Enumeration - the hash enumerate

Overrides:
keys in class java.util.Hashtable<java.lang.Object,java.lang.Object>

toString

public java.lang.String toString()
Return the hashtable as a string

Overrides:
toString in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
String - the hashtable as a string

list

public void list(java.io.PrintWriter out)
List the hashtable to the specific output

Overrides:
list in class java.util.Properties
Parameters:
out - - the print writer

list

public void list(java.io.PrintStream out)
List the hashtable to the specific output

Overrides:
list in class java.util.Properties
Parameters:
out - - the print stream

saveResult

public void saveResult(java.io.OutputStream out,
                       java.lang.String header)
Save the hash to the specific stream

Parameters:
out - - the output stream
header - - the output header

propertyNames

public java.util.Enumeration propertyNames()
get the property names

Overrides:
propertyNames in class java.util.Properties
Returns:
:the hash keys as an enumeration