FileDocCategorySizeDatePackage
StringToStringTableVector.javaAPI DocJava SE 6 API4307Tue Jun 10 00:23:10 BST 2008com.sun.org.apache.xml.internal.utils

StringToStringTableVector

public class StringToStringTableVector extends Object
A very simple table that stores a list of StringToStringTables, optimized for small lists.
xsl.usage
internal

Fields Summary
private int
m_blocksize
Size of blocks to allocate
private StringToStringTable[]
m_map
Array of StringToStringTable objects
private int
m_firstFree
Number of StringToStringTable objects in this array
private int
m_mapSize
Size of this array
Constructors Summary
public StringToStringTableVector()
Default constructor. Note that the default block size is very small, for small lists.


                    
   
  

    m_blocksize = 8;
    m_mapSize = m_blocksize;
    m_map = new StringToStringTable[m_blocksize];
  
public StringToStringTableVector(int blocksize)
Construct a StringToStringTableVector, using the given block size.

param
blocksize Size of blocks to allocate


    m_blocksize = blocksize;
    m_mapSize = blocksize;
    m_map = new StringToStringTable[blocksize];
  
Methods Summary
public final voidaddElement(com.sun.org.apache.xml.internal.utils.StringToStringTable value)
Append a StringToStringTable object onto the vector.

param
value StringToStringTable object to add


    if ((m_firstFree + 1) >= m_mapSize)
    {
      m_mapSize += m_blocksize;

      StringToStringTable newMap[] = new StringToStringTable[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }

    m_map[m_firstFree] = value;

    m_firstFree++;
  
public final booleancontains(com.sun.org.apache.xml.internal.utils.StringToStringTable s)
Tell if the table contains the given StringToStringTable.

param
s The StringToStringTable to find
return
True if the StringToStringTable is found


    for (int i = 0; i < m_firstFree; i++)
    {
      if (m_map[i].equals(s))
        return true;
    }

    return false;
  
public final booleancontainsKey(java.lang.String key)
Given a string, find out if there is a value in this table that matches the key.

param
key String to look for
return
True if the string was found in table, null if not


    for (int i = m_firstFree - 1; i >= 0; --i)
    {
      if (m_map[i].get(key) != null)
        return true;
    }

    return false;
  
public final com.sun.org.apache.xml.internal.utils.StringToStringTableelementAt(int i)
Get the nth element.

param
i Index of element to find
return
The StringToStringTable object at the given index

    return m_map[i];
  
public final java.lang.Stringget(java.lang.String key)
Given a string, find the last added occurance value that matches the key.

param
key String to look up
return
the last added occurance value that matches the key or null if not found.


    for (int i = m_firstFree - 1; i >= 0; --i)
    {
      String nsuri = m_map[i].get(key);

      if (nsuri != null)
        return nsuri;
    }

    return null;
  
public final intgetLength()
Get the length of the list.

return
Number of StringToStringTable objects in the list

    return m_firstFree;
  
public final voidremoveLastElem()
Remove the last element.


    if (m_firstFree > 0)
    {
      m_map[m_firstFree] = null;

      m_firstFree--;
    }
  
public final intsize()
Get the length of the list.

return
Number of StringToStringTable objects in the list

    return m_firstFree;