public class BaseProperties
extends java.lang.Object
implements java.util.Map
Modifier and Type | Class and Description |
---|---|
static class |
BaseProperties.LoadSettingsType
Load Settings Type
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
getEmptyStringDefaultFlag()
Returns the default empty-string-default flag for the property items.
|
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.
|
boolean |
isErrorAddAlreadyExist()
Determines if it is an error to add an item with a name that already
exists.
|
boolean |
isIgnoreUnknownPropertyNames() |
boolean |
isStoreEmptyStringsFlag()
Get the store empty strings flag.
|
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,
BaseProperties.LoadSettingsType loadSettingsType)
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.
|
BaseProperties |
setEmptyStringDefaultFlag(boolean flg)
Sets the default empty-string-default flag for the property items.
|
void |
setErrorAddAlreadyExist(boolean b)
Set if it is an error to add an item with a name that already exists.
|
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.
|
void |
setIgnoreUnknownPropertyNames(boolean b)
Set to ignore unknown property names.
|
protected void |
setIllegalCharMsg(int charVal) |
void |
setLoadedFlags(boolean flgVal)
Sets the 'loadedFlag' field for all items to the given flag value.
|
BaseProperties |
setStoreEmptyStringsFlag(boolean flg)
Set the store empty strings flag.
|
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.
|
public static final java.lang.String SEPARATOR_STRING
public static final java.lang.String SPECIAL_CHARS_STR
protected boolean errMsgSetFlag
protected java.lang.String errorMessage
protected java.lang.String loadedCfgFname
public BaseProperties()
public BaseProperties(CfgPropItem[] itemsArr)
itemsArr
- array of itemspublic BaseProperties(java.util.Map itemsMap)
itemsMap
- items mappublic BaseProperties(java.util.Vector vec)
vec
- vector of itemsprotected static java.lang.String insertQuoteChars(java.lang.Object valueObj, java.lang.String stringValue)
valueObj
- the value object.stringValue
- the string value of the item.public final CfgPropItem add(CfgPropItem item)
If an item with the same name already exists in the table, it is either
replaced if isErrorAddAlreadyExist()
is not true or an
IllegalArgumentException
exception is thrown.
item
- the item to addjava.lang.IllegalArgumentException
- if isErrorAddAlreadyExist()
is true and an item with the same name
already exists in the table.isErrorAddAlreadyExist()
,
setErrorAddAlreadyExist(boolean)
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 void clear()
clear
in interface java.util.Map
java.lang.UnsupportedOperationException
- clear is not supported by this 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 containsKey(java.lang.String name)
name
- key namepublic 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.util.Enumeration elements()
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map
equals
in class java.lang.Object
o
- object to be compared for equality with this map.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 CfgPropItem get(java.lang.String name)
name
- item namepublic java.lang.String getDisplayString()
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 boolean getEmptyStringDefaultFlag()
public java.lang.String getErrorMessage()
public java.lang.String getLoadedCfgFname()
public int hashCode()
hashCode
in interface java.util.Map
hashCode
in class java.lang.Object
Map.Entry#hashCode()
,
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
public boolean isEmpty()
isEmpty
in interface java.util.Map
public boolean isErrorAddAlreadyExist()
public boolean isIgnoreUnknownPropertyNames()
public boolean isStoreEmptyStringsFlag()
public java.util.Enumeration keys()
public java.util.Set keySet()
keySet
in interface java.util.Map
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.io.InputStream inStm, BaseProperties.LoadSettingsType loadSettingsType)
inStm
- an input stream.loadSettingsType
- the load settings type.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 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 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 CfgPropItem remove(CfgPropItem item)
item
- the item to removepublic 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 CfgPropItem remove(java.lang.String name)
name
- item namepublic void setAllToDefaults()
public BaseProperties setEmptyStringDefaultFlag(boolean flg)
flg
- the flag value to use.public void setErrorAddAlreadyExist(boolean b)
b
- true if error, false otherwise.protected void setErrorMessage(java.lang.String str)
str
- error message stringpublic void setIgnoreUnknownPropertyNames(boolean b)
b
- true to ignore unknown property names.protected void setIllegalCharMsg(int charVal)
public void setLoadedFlags(boolean flgVal)
flgVal
- flag valuepublic BaseProperties setStoreEmptyStringsFlag(boolean flg)
flg
- the flag value to use.protected void setUnexpectedEOFMsg()
public int size()
size
in interface java.util.Map
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 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, 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, 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 java.util.Collection values()
values
in interface java.util.Map