com.isti.trinetwatch.ruleset
Class LevelTag

java.lang.Object
  extended by com.isti.trinetwatch.ruleset.LevelTag
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
StatusLevelTag, UsageLevelTag

public class LevelTag
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Class LevelTag defines tag objects which represent status and usage levels.

See Also:
Serialized Form

Constructor Summary
LevelTag(java.lang.String name, int value, int colorRGB, java.lang.String description)
          Creates a LevelTag object.
 
Method Summary
 int compareTo(LevelTag lTag)
          Compares the 'value' field of this object with the 'value' field of the specified object 'lTag'.
 int compareTo(java.lang.Object obj)
          Compares the 'value' field of this object with the 'value' field of the specified object 'obj'.
protected static LevelTag decodeFormattedLTagString(java.lang.String str)
          Decodes an ASCII formatted string into a new object.
 java.lang.String encodeFormattedString()
          Encodes the object into an ASCII formatted string.
 boolean equals(java.lang.Object obj)
          Compares the given LevelTag object to this object.
 boolean equalsIgnoreCase(java.lang.String str)
          Compares the given string to the name string for this object, ignoring case.
 boolean equalsName(java.lang.Object obj)
          Compares the name string of the given LevelTag object to the name string for this object.
 boolean equalsName(java.lang.String str)
          Compares the given string to the name string for this object.
 boolean equalsNum(int num)
          Compares the given integer value to the numeric value for the level.
 int getColorRGB()
          Returns the combined RGB color value for level, consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7 (same as java.awt.Color).
 java.lang.String getDescription()
          Returns description of level.
 java.lang.String getDisplayString()
          Returns displayable string representation of object.
 java.lang.String getName()
          Returns level tag name.
 int getParsePos()
          Returns the parse-position variable.
 int getValue()
          Returns the numeric value for level.
 int hashCode()
          Returns the hash code for this level tag.
protected  void setParsePos(int pos)
          Sets the parse-position variable.
 java.lang.String toString()
          Returns level tag name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LevelTag

public LevelTag(java.lang.String name,
                int value,
                int colorRGB,
                java.lang.String description)
Creates a LevelTag object.

Parameters:
name - level tag name. Any colons in the name are replaced by underscores, for compatibility with the 'encodeFormattedString()' function.
value - numeric value for level.
colorRGB - combined RGB color value for level, consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7 (same as java.awt.Color)--or this can be the value for an ASCII symbol.
description - optional description of level. Any double-quote (") characters in the name are replaced by single-quote (') characters, for compatibility with the 'encodeFormattedString()' function.
Method Detail

getName

public java.lang.String getName()
Returns level tag name.


getValue

public int getValue()
Returns the numeric value for level.


getColorRGB

public int getColorRGB()
Returns the combined RGB color value for level, consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7 (same as java.awt.Color). This value can also be used to represent an ASCII symbol.


getDescription

public java.lang.String getDescription()
Returns description of level.


toString

public java.lang.String toString()
Returns level tag name.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compares the given LevelTag object to this object.

Overrides:
equals in class java.lang.Object

equalsNum

public boolean equalsNum(int num)
Compares the given integer value to the numeric value for the level.


equalsName

public boolean equalsName(java.lang.Object obj)
Compares the name string of the given LevelTag object to the name string for this object.


equalsName

public boolean equalsName(java.lang.String str)
Compares the given string to the name string for this object.


equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.String str)
Compares the given string to the name string for this object, ignoring case.


hashCode

public int hashCode()
Returns the hash code for this level tag.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares the 'value' field of this object with the 'value' field of the specified object 'obj'.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - a LevelTag object to compare to.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object 'obj' is not a LevelTag object.

compareTo

public int compareTo(LevelTag lTag)
Compares the 'value' field of this object with the 'value' field of the specified object 'lTag'.

Parameters:
lTag - a LevelTag object to compare to.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

getParsePos

public int getParsePos()
Returns the parse-position variable. Setup by the 'decodeFormattedString()' function.


setParsePos

protected void setParsePos(int pos)
Sets the parse-position variable.


encodeFormattedString

public java.lang.String encodeFormattedString()
Encodes the object 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.)

Returns:
The encoded ASCII formatted string.

decodeFormattedLTagString

protected static LevelTag decodeFormattedLTagString(java.lang.String str)
Decodes an ASCII formatted string into a new object. 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 formatted string may be terminated by a semicolon (';') or by the end of the string. The ending parse position is saved and may be retrieved via the member function 'getParsePos()'.

Returns:
A new LevelTag object, or null if a syntax error was detected in the string.

getDisplayString

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