All Packages Class Hierarchy This Package Previous Next Index
Interface uhr.core.tron.PropMap
- public interface PropMap
- extends ConvenientStringMap,
Cloneable, Serializable
This interface defines a configurable key value data structure
similar to Hashtable. Its outstanding characteristic is it can
also automatically support tree like behavior, allowing it be
used as a param, tree, etc. We expect to add more configurable
properties.
Keys must be Strings with no spaces allowed. All configurable
properties have sensible defaults. The configurable
properties are:
isNullValueAllowed()
isOrderedKeys()
getNestedKeySeparator()
The implementation should have a no arg constructor and other
constructors for configuration.
NOTE - We are planning to remove this since replaced by Flexitron.
First we will add the ability to auto create with nested keys.
-
clone()
- Returns a shallow copy of the object.
-
containsKey(String)
- Returns true if the collection contains the key, false if not.
-
containsValue(Object)
- Returns true if the collection contains the value, false if not.
-
findFirstKey(Object)
- Returns the first key found for the value, or null if not found.
-
get(String)
- Returns the value to which the specified key is mapped in this
collection.
-
getKeys()
- Returns an enumeration of the keys in this collection.
-
getNestedKeySeparator()
- Returns the nested key separator or null if none in use.
-
getSize()
- Returns the number of key values in the collection, which may be
zero.
-
insertBefore(String,
Object, String)
- Inserts the key and value before the keyBefore.
-
isEmpty()
- Returns true if the collection is empty or false if not.
-
isNullValueAllowed()
- Returns true if null values are allowed, false if not.
-
isOrderedKeys()
- Returns true if ordered keys are maintained, false if not.
-
isTree()
- Returns true if a non-null nested key separator has been set.
-
put(String,
Object)
- Puts the value in the collection and associates it with the key
for retrival.
-
removeAll()
- Removes all keys and values from the collection.
-
removeKey(String)
- Removes the key and its value.
-
removeValue(Object)
- Removes all occurances of the key for this value.
-
toString()
- Returns a comma delimited string of key/values, for example:
"[Name=Pantajeli, Age=11]".
isNullValueAllowed
public abstract boolean isNullValueAllowed()
- Returns true if null values are allowed, false if not. The
default is false.
- Returns:
- whether null values are allowed or not.
isOrderedKeys
public abstract boolean isOrderedKeys()
- Returns true if ordered keys are maintained, false if not.
The default is false.
If true the keys are maintained in the order added. This
allows the order of keys to be preserved, instead of being
random. An example of usefulness is to preserve the order of a
visual tree or list.
- Returns:
- whether ordered keys are maintained or not.
getNestedKeySeparator
public abstract String getNestedKeySeparator()
- Returns the nested key separator or null if none in use.
The default is null.
The separator is used for reads and writes with nested
keys, such as "State.County.Town". This allows very efficient
use of keys for tree structures. This is only useful if a tree
is being used and single keys don't have the separator. The
default is null, meaning none. Common, safe key separators are
"." and "/".
If a key separator has been set, reads and writes will use
automatic nesting, which occurs if a separator is present in the
key.
For example put("Georgia.Dekalb.Clarkston", "2000") would put
"2000" into the path using the key. The call
get("Georgia.Dekalb.Clarkston") would return "2000", as expected.
But the call get("Georgia.Dekalb") returns an OmniTron, and can
be followed by omniTron.get("Clarkston") which returns "2000".
Thus nested OmniTrons can be used to create a clean, easy to use,
tree structure.
- Returns:
- the nested key separator or null if none.
isTree
public abstract boolean isTree()
- Returns true if a non-null nested key separator has been set.
The default is false.
- Returns:
- whether a nested key separator is in use fot a tree
data structure or not.
put
public abstract Object put(String key,
Object value)
- Puts the value in the collection and associates it with the key
for retrival. Any previous value is overwritten.
- Parameters:
- key - the unique identifier for the value.
- value - the Object to associate with the key.
- Returns:
- the previous value with the key, or null if none or
the value was null.
insertBefore
public abstract void insertBefore(String key,
Object value,
String keyBefore)
- Inserts the key and value before the keyBefore. This is only
allowed for ordered collections. The keyBefore must already be
in the collection and the key must not already be in the
collection.
- Parameters:
- key - the unique identifier for the value.
- value - the Object to associate with the key.
- keyBefore - the key to insert the key/value before.
removeKey
public abstract Object removeKey(String key)
- Removes the key and its value.
- Parameters:
- key - the key to remove.
- Returns:
- the value removed, or null if none or the value was null.
removeValue
public abstract int removeValue(Object value)
- Removes all occurances of the key for this value. If the value is
null and null values are allowed, then all keys with null values
are removed, so be careful. :-)
- Parameters:
- value - the value to remove all occurances of.
- Returns:
- the number of keys removed.
removeAll
public abstract void removeAll()
- Removes all keys and values from the collection. Has no effect
on the configuration.
get
public abstract Object get(String key)
- Returns the value to which the specified key is mapped in this
collection.
- Parameters:
- key - the key of the value to retrieve.
- Returns:
- the value for the key, or null if not found or null if
the value was null.
getKeys
public abstract Enumeration getKeys()
- Returns an enumeration of the keys in this collection.
- Returns:
- an enumeration of all the keys, in order if ordered keys.
getSize
public abstract int getSize()
- Returns the number of key values in the collection, which may be
zero. Note this doesn't include children if a tree.
- Returns:
- the size of the collection.
isEmpty
public abstract boolean isEmpty()
- Returns true if the collection is empty or false if not.
- Returns:
- true if empty or false if not.
containsKey
public abstract boolean containsKey(String key)
- Returns true if the collection contains the key, false if not.
- Parameters:
- key - the key to test.
- Returns:
- true if the collection contains the key, false if not.
containsValue
public abstract boolean containsValue(Object value)
- Returns true if the collection contains the value, false if not.
Note that if null values are allowed and the value is null, then
the value may be associated with more than one key.
- Parameters:
- value - the value to test.
- Returns:
- true if the collection contains the value, false if not.
findFirstKey
public abstract String findFirstKey(Object value)
- Returns the first key found for the value, or null if not found.
This may be only useful for ordered keys.
- Parameters:
- value - the value to use to find the key.
- Returns:
- the key found or null if not foubd.
toString
public abstract String toString()
- Returns a comma delimited string of key/values, for example:
"[Name=Pantajeli, Age=11]". If a tree then a tree format is used.
Both are designed to be easily readable.
- Returns:
- the String representation of the collection.
- Overrides:
- toString in class Object
clone
public abstract Object clone()
- Returns a shallow copy of the object.
- Returns:
- a shallow copy of the object.
- Overrides:
- clone in class Object
All Packages Class Hierarchy This Package Previous Next Index