|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.BaseProperties
Class BaseProperties is the base class for classes that manage a table of configuration property items. The 'CfgProperties' class extends this class to add stream loading and saving. The 'AppletProperties' class adds loading of properties as parameters from a host HTML file. Each item has a name, a value, a default value, a loaded-flag (set true if the item has been "loaded" from an input stream), and a required-flag (set true if the item must be loaded from an input stream). A vector or array of 'CfgPropItem' objects may be used to define a set of property names and default-value objects; or they be added individually. The default-value objects determine the data types for the items.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
protected boolean |
errMsgSetFlag
|
protected java.lang.String |
errorMessage
|
protected java.lang.String |
loadedCfgFname
|
static java.lang.String |
SEPARATOR_STRING
The separator string to use to separate values. |
static java.lang.String |
SPECIAL_CHARS_STR
String of special characters for 'insertQuoteChars()' method. |
Constructor Summary | |
BaseProperties()
Creates an empty table of items. |
|
BaseProperties(CfgPropItem[] itemsArr)
Creates a table of items using the given array of 'CfgPropItem' objects. |
|
BaseProperties(java.util.Map itemsMap)
Creates a properties object that uses the specified map of items or creates a new one if no map was specified (null). |
|
BaseProperties(java.util.Vector vec)
Creates a table of items using the given Vector of 'CfgPropItem' objects. |
Method Summary | |
CfgPropItem |
add(CfgPropItem item)
Adds the given property item to the table. |
CfgPropItem |
add(java.lang.String nameStr,
java.lang.Object valueObj)
Creates a new property item and adds it to the table. |
CfgPropItem |
add(java.lang.String nameStr,
java.lang.Object valueObj,
boolean requiredFlag)
Creates a new property item and adds it to the table. |
void |
clear()
Removes all mappings from this map (optional operation). |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsKey(java.lang.String name)
Returns true if the table contains an item whose name matches the given name. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value. |
java.util.Enumeration |
elements()
Returns an enumeration of items in the table. |
java.util.Set |
entrySet()
Returns a set view of the mappings contained in this map. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this map for equality. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified key. |
CfgPropItem |
get(java.lang.String name)
Returns the item in the table matching the given name, or null if no matching item could be found. |
java.lang.String |
getDisplayString()
Returns a string containing a display of the names and values for all the property items in the table. |
java.lang.String |
getDisplayString(java.lang.String equalsStr,
java.lang.String newlineStr)
Returns a string containing a display of the names and values for all the property items in the table. |
java.lang.String |
getErrorMessage()
Returns the text message string corresponding to the first error generated by the 'load()' method, or "No error" if no errors have occurred. |
java.lang.String |
getLoadedCfgFname()
Returns the name of the configuration file that was loaded; or null if no file was loaded. |
int |
hashCode()
Returns the hash code value for this map. |
protected static java.lang.String |
insertQuoteChars(java.lang.Object valueObj,
java.lang.String stringValue)
Returns a string with a backslash quote character ('\') inserted in front of each occurance of a "special" character in the given source string if needed. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
java.util.Enumeration |
keys()
Returns an enumeration of item names in the table. |
java.util.Set |
keySet()
Returns a set view of the keys contained in this map. |
boolean |
load(java.io.InputStream inStm)
Reads a set of property items from the given input stream. |
boolean |
load(java.io.InputStream inStm,
boolean defaultFlag)
Reads a set of property items from the given input stream. |
boolean |
load(java.lang.String inStr)
Reads a set of property items from the given input string. |
boolean |
load(java.lang.String inStr,
boolean defaultFlag)
Reads a set of property items from the given input string. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map (optional operation). |
void |
putAll(java.util.Map t)
Copies all of the mappings from the specified map to this map (optional operation). |
CfgPropItem |
remove(CfgPropItem item)
Removes the given property item from the table. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this map if present (optional operation). |
CfgPropItem |
remove(java.lang.String name)
Removes the item in the table matching the given name. |
void |
setAllToDefaults()
Sets value on all items to the default value. |
protected void |
setErrorMessage(java.lang.String str)
Returns the text message string corresponding to the last error generated by the 'load()' method, or "No error" if no errors have occurred. |
protected void |
setIllegalCharMsg(int charVal)
|
void |
setLoadedFlags(boolean flgVal)
Sets the 'loadedFlag' field for all items to the given flag value. |
protected void |
setUnexpectedEOFMsg()
|
int |
size()
Returns the number of key-value mappings in this map. |
void |
store(java.io.OutputStream outStm,
java.lang.String header,
boolean skipUnloadedFlag)
Stores the properties table to the given output stream in a manner suitable to loading via the 'load()' method. |
void |
store(java.io.OutputStream outStm,
java.lang.String header,
boolean skipUnloadedFlag,
boolean showHeadersFlag,
boolean showCmdLnOnlyFlag)
Stores the properties table to the given output stream in a manner suitable to loading via the 'load()' method. |
void |
store(java.io.OutputStream outStm,
java.lang.String header,
boolean skipUnloadedFlag,
boolean showHeadersFlag,
boolean showCmdLnOnlyFlag,
java.lang.String equalsStr)
Stores the properties table to the given output stream in a manner suitable to loading via the 'load()' method. |
void |
store(java.io.OutputStream outStm,
java.lang.String header,
boolean skipUnloadedFlag,
boolean showHeadersFlag,
boolean showCmdLnOnlyFlag,
java.lang.String equalsStr,
java.lang.String newlineStr)
Stores the properties table to the given output stream in a manner suitable to loading via the 'load()' method. |
java.util.Collection |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String SEPARATOR_STRING
public static final java.lang.String SPECIAL_CHARS_STR
protected java.lang.String errorMessage
protected boolean errMsgSetFlag
protected java.lang.String loadedCfgFname
Constructor Detail |
public BaseProperties(java.util.Map itemsMap)
itemsMap
- items mappublic BaseProperties()
public BaseProperties(java.util.Vector vec)
vec
- vector of itemspublic BaseProperties(CfgPropItem[] itemsArr)
itemsArr
- array of itemsMethod Detail |
public final CfgPropItem add(CfgPropItem item)
item
- the item to add
public CfgPropItem add(java.lang.String nameStr, java.lang.Object valueObj)
nameStr
- the name for the property item.valueObj
- the default value object for the property item.
public CfgPropItem add(java.lang.String nameStr, java.lang.Object valueObj, boolean requiredFlag)
nameStr
- the name for the property item.valueObj
- the default value object for the property item.requiredFlag
- the value for the item's required-flag (see
'CfgPropItem.setRequiredFlag()').
public CfgPropItem remove(java.lang.String name)
name
- item name
public CfgPropItem get(java.lang.String name)
name
- item name
public boolean containsKey(java.lang.String name)
name
- key name
public java.util.Enumeration elements()
public java.util.Enumeration keys()
public CfgPropItem remove(CfgPropItem item)
item
- the item to remove
public void store(java.io.OutputStream outStm, java.lang.String header, boolean skipUnloadedFlag, boolean showHeadersFlag, boolean showCmdLnOnlyFlag, java.lang.String equalsStr, java.lang.String newlineStr) throws java.io.IOException
outStm
- an output stream.header
- a descriptive string which, if not null and contains
data, is written as a leading comment line.skipUnloadedFlag
- if true then only items with their
'loadedFlag' set will be stored, if false then all items will
be stored.showHeadersFlag
- if true then the headers are outputted.showCmdLnOnlyFlag
- if true then items set as "command line
only" will also be stored.equalsStr
- a String containing the characters to be placed
between each name and value; or if null then the characters " = "
will be used.newlineStr
- a String containing the characters to be used to
separate items; or if null then the system default newline
character(s) will be used.
java.io.IOException
- if an I/O error is detected.public void store(java.io.OutputStream outStm, java.lang.String header, boolean skipUnloadedFlag, boolean showHeadersFlag, boolean showCmdLnOnlyFlag, java.lang.String equalsStr) throws java.io.IOException
outStm
- an output stream.header
- a descriptive string which, if not null and contains
data, is written as a leading comment line.skipUnloadedFlag
- if true then only items with their
'loadedFlag' set will be stored, if false then all items will
be stored.showHeadersFlag
- if true then the headers are outputted.showCmdLnOnlyFlag
- if true then items set as "command line
only" will also be stored.equalsStr
- a String containing the characters to be placed
between each name and value; or if null then the characters " = "
will be used.
java.io.IOException
- if an I/O error is detected.public void store(java.io.OutputStream outStm, java.lang.String header, boolean skipUnloadedFlag, boolean showHeadersFlag, boolean showCmdLnOnlyFlag) throws java.io.IOException
outStm
- an output stream.header
- a descriptive string which, if not null and contains
data, is written as a leading comment line.skipUnloadedFlag
- if true then only items with their
'loadedFlag' set will be stored, if false then all items will
be stored.showHeadersFlag
- if true then the headers are outputted.showCmdLnOnlyFlag
- if true then items set as "command line
only" will also be stored.
java.io.IOException
- if an I/O error is detected.public void store(java.io.OutputStream outStm, java.lang.String header, boolean skipUnloadedFlag) throws java.io.IOException
outStm
- an output stream.header
- a descriptive string which, if not null and contains
data, is written as a leading comment line.skipUnloadedFlag
- if true then only items with their
'loadedFlag' set will be stored, if false then all items will
be stored.
java.io.IOException
- if an I/O error is detected.public boolean load(java.io.InputStream inStm)
inStm
- an input stream.
public boolean load(java.io.InputStream inStm, boolean defaultFlag)
inStm
- an input stream.defaultFlag
- true if property items are the defaults, false otherwise.
public boolean load(java.lang.String inStr)
inStr
- the string containing the data to read.
public boolean load(java.lang.String inStr, boolean defaultFlag)
inStr
- the string containing the data to read.defaultFlag
- true if property items are the defaults, false otherwise.
public void setLoadedFlags(boolean flgVal)
flgVal
- flag valueprotected void setErrorMessage(java.lang.String str)
str
- error message stringprotected void setIllegalCharMsg(int charVal)
protected void setUnexpectedEOFMsg()
public java.lang.String getErrorMessage()
public java.lang.String getLoadedCfgFname()
public java.lang.String getDisplayString(java.lang.String equalsStr, java.lang.String newlineStr)
equalsStr
- a String containing the characters to be placed
between each name and value; or if null then the characters " = "
will be used.newlineStr
- a String containing the characters to be used to
separate items; or if null then the system default newline
character(s) will be used.
public java.lang.String getDisplayString()
public int size()
size
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
key
- key whose presence in this map is to be tested.
java.lang.ClassCastException
- if the key is of an inappropriate type for
this map.
java.lang.NullPointerException
- if the key is null and this map
does not not permit null keys.public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
value
- value whose presence in this map is to be tested.
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
key
- key whose associated value is to be returned.
java.lang.ClassCastException
- if the key is of an inappropriate type for
this map.
java.lang.NullPointerException
- key is null and this map does not
not permit null keys.containsKey(Object)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
java.lang.UnsupportedOperationException
- if the put operation is
not supported by this map.
java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.
java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.
java.lang.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- key whose mapping is to be removed from the map.
java.lang.UnsupportedOperationException
- if the remove method is
not supported by this map.public void putAll(java.util.Map t)
putAll
in interface java.util.Map
t
- Mappings to be stored in this map.
java.lang.UnsupportedOperationException
- if the putAll method is
not supported by this map.
java.lang.ClassCastException
- if the class of a key or value in the
specified map prevents it from being stored in this map.
java.lang.IllegalArgumentException
- some aspect of a key or value in the
specified map prevents it from being stored in this map.
java.lang.NullPointerException
- this map does not permit null
keys or values, and the specified key or value is
null.public void clear()
clear
in interface java.util.Map
java.lang.UnsupportedOperationException
- clear is not supported by this
map.public void setAllToDefaults()
public java.util.Set keySet()
keySet
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map
o
- object to be compared for equality with this map.
public int hashCode()
hashCode
in interface java.util.Map
Map.Entry#hashCode()
,
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
protected static java.lang.String insertQuoteChars(java.lang.Object valueObj, java.lang.String stringValue)
valueObj
- the value object.stringValue
- the string value of the item.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |