ewe.util
Class TagList

java.lang.Object
  extended byewe.util.TagList

public class TagList
extends Object

A TagList stores a list of Tags (a positive integer tag value associated with an Object value) using arrays of integers and object references instead of arrays of Tag objects.

A TagList only allows the storage of one Object value for each distinct Tag value. That is, if you call set(int tag, Object value) and a value already exists for that integer tag value, then this new value will overwrite the old one.


Field Summary
static int EmptyTag
           
 int expandSize
           
protected  int num
           
 
Constructor Summary
TagList()
           
 
Method Summary
 void clear(int tag)
          Remove a tag value.
 void defaultTo(int tag, Object value)
          Set a value for a tag if it has not already been set.
 Tag get(int tag, Tag dest)
          Get the tag Object for the specified tag integer value.
 Tag getAtIndex(int index, Tag dest)
          Get the tag at the specified index.
protected  int getEmptyIndex()
           
protected  int getTagIndex(int tag)
           
 Object getValue(int tag, Object defaultValue)
           
 boolean hasTag(int tag)
          Check if the specified tag has a value set for it.
 void set(int tag, Object value)
          Set the Object value for a tag.
 void set(TagList tl)
          Set all the tag values from the other TagList.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

num

protected int num

expandSize

public int expandSize

EmptyTag

public static final int EmptyTag
See Also:
Constant Field Values
Constructor Detail

TagList

public TagList()
Method Detail

size

public int size()

getTagIndex

protected int getTagIndex(int tag)

getEmptyIndex

protected int getEmptyIndex()

getAtIndex

public Tag getAtIndex(int index,
                      Tag dest)
Get the tag at the specified index. A tag value of EmptyTag (-1) indicates not tag value stored at that point.


get

public Tag get(int tag,
               Tag dest)
Get the tag Object for the specified tag integer value.

Parameters:
tag - The integer tag value to look for.
dest - An optional destination tag object.
Returns:
The destination or new Tag object containing the tag data, or null if the tag value is not stored.

getValue

public Object getValue(int tag,
                       Object defaultValue)
Parameters:
tag - The integer tag value to look for.
defaultValue - a default Object value to return if the tag is not found
Returns:
The object value of that tag, or the default value if it is not found.

set

public void set(int tag,
                Object value)
Set the Object value for a tag.

Parameters:
tag - The integer tag value to set.
value - The Object value to set.

set

public void set(TagList tl)
Set all the tag values from the other TagList.

Parameters:
tl - Another TagList to copy values from.

clear

public void clear(int tag)
Remove a tag value.

Parameters:
tag - The integer tag value to remove.

defaultTo

public void defaultTo(int tag,
                      Object value)
Set a value for a tag if it has not already been set.

Parameters:
tag - The integer tag value.
value - The object tag value.

hasTag

public boolean hasTag(int tag)
Check if the specified tag has a value set for it.

Parameters:
tag - The integer tag value to check for.