com.isti.trinetwatch.ruleset
Class LevelTagTable

java.lang.Object
  extended by com.isti.trinetwatch.ruleset.LevelTagTable
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
StatusLevelTable, UsageLevelTable

public abstract class LevelTagTable
extends java.lang.Object
implements java.io.Serializable

Class LevelTagTable manages a table of LevelTag objects. A modified hash table implementation is used which allows for both the string 'name' and numeric 'value' fields to be used as search keys.

See Also:
Serialized Form

Field Summary
protected  FifoHashtable hTable
           
protected  LevelTag[] levelTagArray
           
protected static int LT_ARRAY_SIZE
           
protected  int maxTagValue
           
protected  int minTagValue
           
 
Constructor Summary
LevelTagTable()
           
 
Method Summary
protected  boolean add(LevelTag lTag)
          Adds LevelTag object to table.
 boolean addLevelTag(LevelTag lTag)
          Adds LevelTag object to table.
 void clear()
          Clears all objects in the table.
 boolean containsKey(java.lang.String str)
          Returns true if the specified key exists in the table.
protected  boolean containsValue(LevelTag lTag)
          Returns true if the specified LevelTag object exists in the table.
 java.util.Enumeration elements()
          Returns an enumeration of the LevelTag objects in the table.
 java.lang.String encodeFormattedString()
          Encodes the table into an ASCII formatted string.
 int getMaxTagValue()
          Returns the maximum 'LevelTag.getValue()' value in the table.
 int getMinTagValue()
          Returns the minimum 'LevelTag.getValue()' value in the table.
 java.lang.Object getTableSyncObj()
          Returns the thread-synchronization object for this table.
 LevelTag getTag(int num)
          Returns LevelTag object associated with the given numeric value.
 LevelTag getTag(java.lang.String str)
          Returns LevelTag object associated with the given key.
 java.awt.Color getTagColorObj(java.lang.String name, java.awt.Color defaultObj)
          Returns a Color object representing the '.colorRGB' value for the matching tag object in the table.
 char getTagSymbolChar(java.lang.String name, char defaultChar)
          Returns a character value representing the symbol value for the matching tag object in the table (stored in the '.colorRGB' member of the tag object).
 java.util.Vector getValuesVector()
          Returns a new Vector containing the values in the table.
protected  LevelTag removeTag(int num)
          Removes LevelTag object associated with the given numeric value.
protected  LevelTag removeTag(LevelTag lTag)
          Removes the given LevelTag object.
protected  LevelTag removeTag(java.lang.String str)
          Removes LevelTag object associated with the given key.
 void replaceTableData(LevelTagTable srcTableObj)
          Replaces the data in this table with data from the given table.
 int size()
          Returns the number of LevelTag objects in the table.
 java.lang.String toString()
          Returns string representation of object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LT_ARRAY_SIZE

protected static final int LT_ARRAY_SIZE
See Also:
Constant Field Values

hTable

protected final FifoHashtable hTable

levelTagArray

protected final LevelTag[] levelTagArray

minTagValue

protected int minTagValue

maxTagValue

protected int maxTagValue
Constructor Detail

LevelTagTable

public LevelTagTable()
Method Detail

add

protected boolean add(LevelTag lTag)
Adds LevelTag object to table.

Parameters:
lTag - LevelTag object to be added.
Returns:
true if successful, false if a object with the same name or number already exists in table or if an invalid parameter is detected.

addLevelTag

public boolean addLevelTag(LevelTag lTag)
Adds LevelTag object to table.

Parameters:
lTag - LevelTag object to be added.
Returns:
true if successful, false if a object with the same name or number already exists in table or if an invalid parameter is detected.

getTag

public LevelTag getTag(java.lang.String str)
Returns LevelTag object associated with the given key.

Parameters:
str - a string matching the contents of the 'name' field of the desired LevelTag object.
Returns:
The handle of the LevelTag object or null if no matching object was found.

getTag

public LevelTag getTag(int num)
Returns LevelTag object associated with the given numeric value.

Parameters:
num - a number matching the contents of the 'value' field of the desired LevelTag object.
Returns:
The handle of the LevelTag object or null if no matching object was found.

removeTag

protected LevelTag removeTag(LevelTag lTag)
Removes the given LevelTag object.

Parameters:
lTag - LevelTag object to be removed.
Returns:
The handle of the LevelTag object which was removed or null if no matching object was found.

removeTag

protected LevelTag removeTag(java.lang.String str)
Removes LevelTag object associated with the given key.

Parameters:
str - a string matching the contents of the 'name' field of the LevelTag object to be removed.
Returns:
The handle of the LevelTag object which was removed or null if no matching object was found.

removeTag

protected LevelTag removeTag(int num)
Removes LevelTag object associated with the given numeric value.

Parameters:
num - a number matching the contents of the 'value' field of the LevelTag object to be removed.
Returns:
The handle of the LevelTag object which was removed or null if no matching object was found.

clear

public void clear()
Clears all objects in the table.


containsValue

protected boolean containsValue(LevelTag lTag)
Returns true if the specified LevelTag object exists in the table.

Parameters:
lTag - LevelTag object to check against.
Returns:
true if the specified LevelTag object exists in the table.

containsKey

public boolean containsKey(java.lang.String str)
Returns true if the specified key exists in the table.

Parameters:
str - key string to use.
Returns:
true if the specified key exists in the table.

elements

public java.util.Enumeration elements()
Returns an enumeration of the LevelTag objects in the table.

Returns:
an enumeration of the LevelTag objects in the table.

size

public int size()
Returns the number of LevelTag objects in the table.

Returns:
the number of LevelTag objects in the table.

getValuesVector

public java.util.Vector getValuesVector()
Returns a new Vector containing the values in the table. The data in the the returned Vector will not be affected by later modifications to the table, and the table will not be affected by modifications to the returned Vector.

Returns:
A new Vector containing the values in the table.

getMinTagValue

public int getMinTagValue()
Returns the minimum 'LevelTag.getValue()' value in the table. Note that the 'remove' functions do not affect this value.

Returns:
The minimum 'LevelTag.getValue()' value in the table or 'Integer.MAX_VALUE' if the table is empty.

getMaxTagValue

public int getMaxTagValue()
Returns the maximum 'LevelTag.getValue()' value in the table. Note that the 'remove' functions do not affect this value.

Returns:
The maximum 'LevelTag.getValue()' value in the table or 'Integer.MIN_VALUE' if the table is empty.

toString

public java.lang.String toString()
Returns string representation of object.

Overrides:
toString in class java.lang.Object
Returns:
String representation of object.

encodeFormattedString

public java.lang.String encodeFormattedString()
Encodes the table into an ASCII formatted string. The format is as follows: [NNNN:VV,CCCC,"DDDD";...] (without the '[]' brackets), where NNNN is the level tag name, VV is its numeric value, CCCC is a numeric RGB color value and DDDD is a description. (The DDDD item is optional.) The items are separated by semicolons (';').

Returns:
The encoded ASCII formatted string.

getTagColorObj

public java.awt.Color getTagColorObj(java.lang.String name,
                                     java.awt.Color defaultObj)
Returns a Color object representing the '.colorRGB' value for the matching tag object in the table. If a matching tag object is not found, then the given default color object is returned.

Parameters:
name - the tag name to match in the table.
defaultObj - the default color object to return if a matching tag object is not found.
Returns:
A Color object.

getTagSymbolChar

public char getTagSymbolChar(java.lang.String name,
                             char defaultChar)
Returns a character value representing the symbol value for the matching tag object in the table (stored in the '.colorRGB' member of the tag object). If a matching tag object is not found or if the symbol value is not valid for a displayable character then the the given default character value is returned.

Parameters:
name - the tag name to match in the table.
defaultChar - the default character value to return if a valid symbol value cannot be generated.
Returns:
A 'char' value.

getTableSyncObj

public java.lang.Object getTableSyncObj()
Returns the thread-synchronization object for this table.

Returns:
The thread-synchronization object for this table.

replaceTableData

public void replaceTableData(LevelTagTable srcTableObj)
Replaces the data in this table with data from the given table.

Parameters:
srcTableObj - source table to read from.