org.apache.xml.utils
Class StringToStringTable

java.lang.Object
  extended by org.apache.xml.utils.StringToStringTable

public class StringToStringTable
extends java.lang.Object

A very simple lookup table that stores a list of strings, the even number strings being keys, and the odd number strings being values.


Field Summary
private  int m_blocksize
          Size of blocks to allocate
private  int m_firstFree
          Number of strings this contains
private  java.lang.String[] m_map
          Array of strings this contains
private  int m_mapSize
          Size of this table
 
Constructor Summary
StringToStringTable()
          Default constructor.
StringToStringTable(int blocksize)
          Construct a StringToStringTable, using the given block size.
 
Method Summary
 boolean contains(java.lang.String key)
          Tell if the table contains the given string.
 boolean containsValue(java.lang.String val)
          Tell if the table contains the given string.
 java.lang.String elementAt(int i)
          Get the nth element.
 java.lang.String get(java.lang.String key)
          Tell if the table contains the given string.
 java.lang.String getByValue(java.lang.String val)
          Tell if the table contains the given string in the value.
 java.lang.String getIgnoreCase(java.lang.String key)
          Tell if the table contains the given string.
 int getLength()
          Get the length of the list.
 void put(java.lang.String key, java.lang.String value)
          Append a string onto the vector.
 void remove(java.lang.String key)
          Remove the given string and its value from this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_blocksize

private int m_blocksize
Size of blocks to allocate


m_map

private java.lang.String[] m_map
Array of strings this contains


m_firstFree

private int m_firstFree
Number of strings this contains


m_mapSize

private int m_mapSize
Size of this table

Constructor Detail

StringToStringTable

public StringToStringTable()
Default constructor. Note that the default block size is very small, for small lists.


StringToStringTable

public StringToStringTable(int blocksize)
Construct a StringToStringTable, using the given block size.

Parameters:
blocksize - Size of blocks to allocate
Method Detail

getLength

public final int getLength()
Get the length of the list.

Returns:
Number of strings in the list

put

public final void put(java.lang.String key,
                      java.lang.String value)
Append a string onto the vector. The strings go to the even locations in the array and the values in the odd.

Parameters:
key - String to add to the list
value - Value of the string

get

public final java.lang.String get(java.lang.String key)
Tell if the table contains the given string.

Parameters:
key - String to look up
Returns:
return the value of the string or null if not found.

remove

public final void remove(java.lang.String key)
Remove the given string and its value from this table.

Parameters:
key - String to remove from the table

getIgnoreCase

public final java.lang.String getIgnoreCase(java.lang.String key)
Tell if the table contains the given string. Ignore case

Parameters:
key - String to look up
Returns:
The value of the string or null if not found

getByValue

public final java.lang.String getByValue(java.lang.String val)
Tell if the table contains the given string in the value.

Parameters:
val - Value of the string to look up
Returns:
the string associated with the given value or null if not found

elementAt

public final java.lang.String elementAt(int i)
Get the nth element.

Parameters:
i - index of the string to look up.
Returns:
The string at the given index.

contains

public final boolean contains(java.lang.String key)
Tell if the table contains the given string.

Parameters:
key - String to look up
Returns:
True if the given string is in this table

containsValue

public final boolean containsValue(java.lang.String val)
Tell if the table contains the given string.

Parameters:
val - value to look up
Returns:
True if the given value is in the table.