All Packages Class Hierarchy This Package Previous Next Index
Class uhr.core.tron.FlexitronStd
java.lang.Object
|
+----uhr.core.tron.ConvenientStringMapStd
|
+----uhr.core.tron.FlexitronStd
- public class FlexitronStd
- extends ConvenientStringMapStd
- implements Flexitron
This interface defines a flexible datatron that can meet a vast
variety of needs. See
full documentation.
Implementation status - No key path, which is terribly complex.
-
FlexitronStd()
- Creates a new FlexitronStd with the default configuration.
-
FlexitronStd(boolean, boolean, boolean, String)
- Creates a new FlexitronStd configured with the values provided.
-
add(String, Object)
- Adds the value in the collection and associates it with the key
for retrival.
-
containsElement(Element)
- Returns true if the collection contains the element, false if not.
-
containsKey(String)
- Returns true if the collection contains the key, false if not.
-
get(String)
- Returns the value to which the specified key is mapped in this
collection.
-
getElements()
- Returns an enumeration of the elements in this collection.
-
getKeys()
- Returns an enumeration of the keys in this collection.
-
getKeySeparator()
- Returns the nested key separator or null if none in use.
-
getSize()
- Returns the number of key values or elements in the collection,
which may be zero.
-
isAutoDetectDuplicateKeys()
- Determines whether the collection will automatically switch to
isElemental() if a duplicate key is added.
-
isElemental()
- Determines whether the collection has Elements or key values.
-
isElementalOnly()
- Determines whether if only elements are maintained.
-
isEmpty()
- Returns true if the collection is empty or false if not.
-
isNullValueAllowed()
- Determines whether null values are allowed.
-
removeAll()
- Removes all keys and values from the collection.
-
removeElement(Element)
- Removes the first occurance of the element from the collection.
-
removeKey(String)
- Removes the key and its value.
-
toString()
- Returns a comma delimited string of key/values, for example:
"[Name=Pantajeli, Age=11]".
FlexitronStd
public FlexitronStd()
- Creates a new FlexitronStd with the default configuration. This is
the same as
new FlexitronStd(false, false, false, null).
FlexitronStd
public FlexitronStd(boolean isElementalOnly,
boolean isAutoDetectDuplicateKeys,
boolean isNullValueAllowed,
String keySeparator)
- Creates a new FlexitronStd configured with the values provided.
For use as a data structure for parsed XML, we recommend:
- isElementalOnly = false
- isAutoDetectDuplicateKeys = true
- isNullValueAllowed = true (empty tags are null)
- keySeparator = "/"
- Parameters:
- isElementalOnly - true to maintain elements only, false
to maintain elements and keyed values.
- isAutoDetectDuplicateKeys - true to automatically switch
to isElemental() if a duplicate key is added, false to not
allow duplicate keys.
- isNullValueAllowed - true to allow null values, false to
not allow null values.
- keySeparator - the key separator to use or null for none.
isElementalOnly
public boolean isElementalOnly()
- Determines whether if only elements are maintained. The default
is false. True is the same as the collection behaving like a
Vector. False allows maintaining keyed values and the
elements.
- Returns:
- true if only elements are maintained, false if not.
isAutoDetectDuplicateKeys
public boolean isAutoDetectDuplicateKeys()
- Determines whether the collection will automatically switch to
isElemental() if a duplicate key is added. True allows this to
happen, false prevents it and duplicate keys.
- Returns:
- true if the feature is on, false if off.
isNullValueAllowed
public boolean isNullValueAllowed()
- Determines whether null values are allowed. A null can be a
perfectly valid data value in some designs, so we support it.
- Returns:
- true if null values are allowed, false if not.
getKeySeparator
public String getKeySeparator()
- Returns the nested key separator or null if none in use.
The default is null.
The separator is used for reads with nested keys, such as
get("State/County/Georgia.Fulton") where "/" is the separator.
We recommend not using "." as the separator to allow the use of
more meaningful keys. Naturally we recommend "/" for the
separator.
isElemental
public boolean isElemental()
- Determines whether the collection has Elements or key values.
- Returns:
- true if is using Elements, false if using key values.
add
public void add(String key,
Object value)
- Adds the value in the collection and associates it with the key
for retrival. If the key is a duplicate and IsAutoDetectDuplicateKeys
is true, then the key and value are put into an Element, and
the collection is said to be "elemental".
- Parameters:
- key - the unique identifier for the value.
- value - the Object to associate with the key.
- Throws: IllegalStateException
- if the key is a duplicate and
IsAutoDetectDuplicateKeys is false.
- Throws: IllegalArgumentException
- if the key is null.
removeKey
public Object removeKey(String key)
- Removes the key and its value. This is only for not is Elemental.
- Parameters:
- key - the key to remove.
- Returns:
- the value removed, or null if none or the value was null.
- Throws: IllegalStateException
- if the collection is Elemental.
removeElement
public boolean removeElement(Element element)
- Removes the first occurance of the element from the collection.
Since you may not have the actual element to remove, create a
new one with the desired key and value. This is used to match
the one to remove. This is only for is Elemental.
- Parameters:
- element - the element to remove.
- Returns:
- true if the element was removed, false if not.
- Throws: IllegalStateException
- if the collection is not Elemental.
removeAll
public void removeAll()
- Removes all keys and values from the collection. Has no effect
on the configuration.
get
public Object get(String key)
- Returns the value to which the specified key is mapped in this
collection. Do not use if isElemental().
If a key separator is in use and the separator is present in the
key, then the nested key value is returned. Note this assumes
that nested keys except the last are Flexitrons. For example
the key "State/County/Georgia.Fulton" implies that a Flexitron
was added to this collection with the key of "State" and it
contained a key of "County" with a Flexitron value that had a
key of "Georgia.Fulton" with an arbitrary value, which is what
is returned.
- 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.
- Throws: IllegalStateException
- if isElemental() or if the
nested key is incompatable with the actual contents.
getKeys
public Enumeration getKeys()
- Returns an enumeration of the keys in this collection.
Do not use if isElemental().
- Returns:
- an enumeration of all the keys, in order if ordered keys.
- Throws: IllegalStateException
- if isElemental();
getElements
public Enumeration getElements()
- Returns an enumeration of the elements in this collection.
- Returns:
- an enumeration of all the elements in order.
getSize
public int getSize()
- Returns the number of key values or elements in the collection,
which may be zero. Note this doesn't include children if a tree.
- Returns:
- the size of the collection.
isEmpty
public boolean isEmpty()
- Returns true if the collection is empty or false if not.
- Returns:
- true if empty or false if not.
containsKey
public boolean containsKey(String key)
- Returns true if the collection contains the key, false if not.
Do not use if isElemental().
- Parameters:
- key - the key to test.
- Returns:
- true if the collection contains the key, false if not.
- Throws: IllegalStateException
- if isElemental();
containsElement
public boolean containsElement(Element element)
- Returns true if the collection contains the element, false if not.
- Parameters:
- element - the element to test.
- Returns:
- true if the collection contains the element, false if not.
toString
public 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
All Packages Class Hierarchy This Package Previous Next Index