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.


Constructor Index

 o FlexitronStd()
Creates a new FlexitronStd with the default configuration.
 o FlexitronStd(boolean, boolean, boolean, String)
Creates a new FlexitronStd configured with the values provided.

Method Index

 o add(String, Object)
Adds the value in the collection and associates it with the key for retrival.
 o containsElement(Element)
Returns true if the collection contains the element, false if not.
 o containsKey(String)
Returns true if the collection contains the key, false if not.
 o get(String)
Returns the value to which the specified key is mapped in this collection.
 o getElements()
Returns an enumeration of the elements in this collection.
 o getKeys()
Returns an enumeration of the keys in this collection.
 o getKeySeparator()
Returns the nested key separator or null if none in use.
 o getSize()
Returns the number of key values or elements in the collection, which may be zero.
 o isAutoDetectDuplicateKeys()
Determines whether the collection will automatically switch to isElemental() if a duplicate key is added.
 o isElemental()
Determines whether the collection has Elements or key values.
 o isElementalOnly()
Determines whether if only elements are maintained.
 o isEmpty()
Returns true if the collection is empty or false if not.
 o isNullValueAllowed()
Determines whether null values are allowed.
 o removeAll()
Removes all keys and values from the collection.
 o removeElement(Element)
Removes the first occurance of the element from the collection.
 o removeKey(String)
Removes the key and its value.
 o toString()
Returns a comma delimited string of key/values, for example: "[Name=Pantajeli, Age=11]".

Constructors

 o FlexitronStd
 public FlexitronStd()
Creates a new FlexitronStd with the default configuration. This is the same as new FlexitronStd(false, false, false, null).

 o 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.

Methods

 o 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.
 o 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.
 o 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.
 o 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.

 o isElemental
 public boolean isElemental()
Determines whether the collection has Elements or key values.

Returns:
true if is using Elements, false if using key values.
 o 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.
 o 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.
 o 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.
 o removeAll
 public void removeAll()
Removes all keys and values from the collection. Has no effect on the configuration.

 o 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.
 o 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();
 o getElements
 public Enumeration getElements()
Returns an enumeration of the elements in this collection.

Returns:
an enumeration of all the elements in order.
 o 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.
 o isEmpty
 public boolean isEmpty()
Returns true if the collection is empty or false if not.

Returns:
true if empty or false if not.
 o 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();
 o 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.
 o 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