|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.retek.commons.gui.util.RPropertyBundle
This class loads a property file consisting of a KEY = VALUE pairs, usually on each line of the file. RPropertyBundle places these keys and values in a HashMap for storage as Strings. The KEY may contain spaces, colons and semi-colons, but may NOT contain an "=" sign. It is the only prohibited part of the key.
The character "\" at the end of a line signifies line continuance allowing multiple lines to make up a single key-value pair. The "!" or "#" at the beginning of a line indicate a comment line and will be ignored, as will a blank line.
This class contains a set of methods to retrieve the information in the property file in different formats. It currently supports Boolean, Integer, Double, String and String[].
An absolute filename will automatically be used. If only a filename is supplied, this bundle looks first in the execution directory and then in the classpath to find the file. This class uses the PROPERTY_ENCODING variable of Utility to set the file encoding that will be used to read in the property file. The default value is UTF-16 format, the standard Unicode format on Windows platform.
Retek Inc. Copyright (c) 2002
Constructor Summary | |
RPropertyBundle()
Creates and returns new empty RPropertyBundle object. |
|
RPropertyBundle(java.lang.String filename)
Creates and returns a new RPropertyBundle object. |
|
RPropertyBundle(java.lang.String filename,
java.lang.String encoding)
Creates and returns a new RPropertyBundle object. |
Method Summary | |
void |
clear()
Removes all key/value pairs from the property bundle. |
java.lang.Boolean |
getBoolean(java.lang.String key)
Retrieves a property value for the given key as an Boolean object. |
char |
getChar(java.lang.String key)
Retrieves a property value for the given key as an Boolean object. |
java.lang.Double |
getDouble(java.lang.String key)
Retrieves a property value for the given key as an Double object. |
java.lang.Integer |
getInteger(java.lang.String key)
Retrieves a property value for the given key as an Integer object. |
java.lang.String[] |
getKeys()
Retrieves a string array of the entire key set of the bundle. |
java.lang.String |
getString(java.lang.String key)
Retrieves a property value for the given key as a String object. |
java.lang.String[] |
getStringArray(java.lang.String key)
Retrieves a property value for the given key as a String array. |
boolean |
isEmpty()
Retrieves whether or not the property bundle is empty. |
void |
loadPropertyBundle(java.lang.String filename)
Loads a file into the property resource bundle, parsing the KEY-VALUE information stored within the file and stores it internally. |
void |
loadPropertyBundle(java.lang.String filename,
java.lang.String encoding)
Loads a file into the property resource bundle, parsing the KEY-VALUE information stored within the file and storing it internally. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RPropertyBundle()
public RPropertyBundle(java.lang.String filename) throws UiBundleException
filename
- The file name of the property file to load.
UiBundleException
- Thrown if the method fails to load the property bundle file.public RPropertyBundle(java.lang.String filename, java.lang.String encoding) throws UiBundleException
filename
- The file name of the property file to load.encoding
- The character encoding to use when reading the property file.
UiBundleException
- Thrown if the method fails to load the property bundle file.Method Detail |
public void clear()
public boolean isEmpty()
public java.lang.String[] getKeys()
public char getChar(java.lang.String key)
key
- The key to retrieve a property value for.
public java.lang.Boolean getBoolean(java.lang.String key)
key
- The key to retrieve a property value for.
public java.lang.Integer getInteger(java.lang.String key)
key
- The key to retrieve a property value for.
public java.lang.Double getDouble(java.lang.String key)
key
- The key to retrieve a property value for.
public java.lang.String getString(java.lang.String key)
key
- The key to retrieve a property value for.
public java.lang.String[] getStringArray(java.lang.String key)
key
- The key to retrieve a property value for.
public void loadPropertyBundle(java.lang.String filename) throws UiBundleException
Note that this method does not clear the bundle before loading the file. This allows for loading multiple files into the same property bundle.
filename
- The file name of the property file to load.
UiBundleException
- Thrown if the fileName is not a valid file, a file IO error
occurs, or the data in the file is not properly formatted.public void loadPropertyBundle(java.lang.String filename, java.lang.String encoding) throws UiBundleException
Note that this method does not clear the bundle before loading the file. This allows for loading multiple files into the same property bundle.
Notes that this method checks for at least 3 bytes of information exists in the file so that it doesn't attempt to read empty Unicode files where the first two bytes indicate only the encoding.
filename
- The file name of the property file to load.encoding
- The character encoding to use when reading the file.
UiBundleException
- Thrown if the fileName is not a valid file, a file IO error
occurs, or the data in the file is not properly formatted.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |