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 containsEntry(Entry)
Returns true if the collection contains the Entry, false if not.
 o containsKey(String)
Returns true if the collection contains the key, false if not.
 o enumerateEntrys()
Returns an enumeration of the Entrys in this collection.
 o enumerateKeys()
Returns an enumeration of the keys in this collection.
 o get(String)
Returns the value to which the specified key is mapped in this collection.
 o getEntryAt(int)
Returns the Entry at the specified index.
 o getFlexitron(String)
Returns the value for the key, cast to a Flexitron.
 o getKeySeparator()
Returns the nested key separator or null if none in use.
 o getSize()
Returns the number of key values or Entrys in the collection, which may be zero.
 o getValueAt(int)
Returns the value at the specified index in the Entrys.
 o insertBefore(String, Object, String)
Inserts the key and value before the first keyBefore.
 o isAutoDetectDuplicateKeys()
Determines whether the collection will automatically switch to isEntrymental() equals true if a duplicate key is added.
 o isEmpty()
Returns true if the collection is empty or false if not.
 o isEntrymental()
Determines whether the collection has only Entrys (true) or has Entrys and key values.
 o isEntrysOnly()
Determines whether only Entrys are maintained.
 o isNullValueAllowed()
Determines whether null values are allowed.
 o removeAll()
Removes all keys and values from the collection, returning it to its original post constructor state.
 o removeEntry(Entry)
Removes the first occurance of the Entry from the collection.
 o removeKey(String)
Removes the key and its value.
 o replicate()
Returns a copy of itself with identical configuration but no data.
 o setContents(Flexitron)
Sets the entire contents of this Flexitron with the keys and values of the contents, including the configuration of the contents.
 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 isEntrysOnly,
                     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:

   - isEntrysOnly = false
   - isAutoDetectDuplicateKeys = true
   - isNullValueAllowed = true (empty tags are null)
   - keySeparator = "/"
 

Parameters:
isEntrysOnly - true to maintain Entrys only, false to maintain Entrys and keyed values.
isAutoDetectDuplicateKeys - true to automatically switch to isEntrymental() 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 replicate
 public Object replicate()
Returns a copy of itself with identical configuration but no data.

Returns:
the replication.
 o isEntrysOnly
 public boolean isEntrysOnly()
Determines whether only Entrys are maintained. The default is false. True is the same as the collection behaving like a Vector. False allows maintaining keyed values and the Entrys.

Returns:
true if only Entrys are maintained, false if not.
 o isAutoDetectDuplicateKeys
 public boolean isAutoDetectDuplicateKeys()
Determines whether the collection will automatically switch to isEntrymental() equals true 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 isEntrymental
 public boolean isEntrymental()
Determines whether the collection has only Entrys (true) or has Entrys and key values. A collection that is using only Entrys is said to be "entrymental".

Returns:
true if using only Entrys, false if not.
 o setContents
 public void setContents(Flexitron contents)
Sets the entire contents of this Flexitron with the keys and values of the contents, including the configuration of the contents. This is very handy for popping Flexitron data into a Message.

Parameters:
contents - the entire new contents of this Flexitron.
 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 Entry, and the collection is said to be "entrymental".

If the value is a Flexitron then its values can be retreived with a nested key such as "State/County/Georgia.Fulton".

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 insertBefore
 public void insertBefore(String key,
                          Object value,
                          String keyBefore)
Inserts the key and value before the first keyBefore. 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.
 o removeKey
 public Object removeKey(String key)
Removes the key and its value. This is only for not isEntrymental().

Parameters:
key - the key to remove.
Returns:
the value removed, or null if none or the value was null.
Throws: IllegalStateException
if the collection isEntrymental().
 o removeEntry
 public boolean removeEntry(Entry entry)
Removes the first occurance of the Entry from the collection. Since you may not have the actual Entry 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 isEntrymental().

Parameters:
entry - the Entry to remove.
Returns:
true if the Entry was removed, false if not.
Throws: IllegalStateException
if the collection is not Entrymental.
 o removeAll
 public void removeAll()
Removes all keys and values from the collection, returning it to its original post constructor state. 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 isEntrymental().

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 isEntrymental() or if the nested key is incompatable with the actual contents.
 o getFlexitron
 public Flexitron getFlexitron(String key)
Returns the value for the key, cast to a Flexitron. This is extremely useful in nexted key data structures. It yields more concise code.

Parameters:
key - the key of the value to return.
Returns:
the value for the key or null if none.
Throws: ClassCastException
if the value is not null and not a Flexitron.
 o getEntryAt
 public Entry getEntryAt(int index)
Returns the Entry at the specified index.

Parameters:
index - the index of interest.
Returns:
the Entry at the index.
Throws: ArrayIndexOutOfBoundsException
if invalid index.
 o getValueAt
 public Object getValueAt(int index)
Returns the value at the specified index in the Entrys.

Parameters:
index - the Entry index of interest.
Returns:
the value in the Entry at the index.
Throws: ArrayIndexOutOfBoundsException
if invalid index.
 o enumerateKeys
 public Enumeration enumerateKeys()
Returns an enumeration of the keys in this collection. Do not use if isEntrymental().

Returns:
an enumeration of all the keys, in order if ordered keys.
Throws: IllegalStateException
if isEntrymental();
 o enumerateEntrys
 public Enumeration enumerateEntrys()
Returns an enumeration of the Entrys in this collection.

Returns:
an enumeration of all the Entrys in order.
 o getSize
 public int getSize()
Returns the number of key values or Entrys 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 isEntrymental().

Parameters:
key - the key to test.
Returns:
true if the collection contains the key, false if not.
Throws: IllegalStateException
if isEntrymental();
 o containsEntry
 public boolean containsEntry(Entry entry)
Returns true if the collection contains the Entry, false if not.

Parameters:
entry - the Entry to test.
Returns:
true if the collection contains the entry, 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