edu.unh.sdb.common
Class TypeTable

java.lang.Object
  extended by edu.unh.sdb.common.TypeTable

public class TypeTable
extends java.lang.Object

The TypeTable class keeps track of user defined types in an internal data structure. Types may be retrieved by name or by typecode, an int greater than zero. Typecodes are assigned when a new user defined type is inserted into the typetable.


Field Summary
static int invalidTypeCode
          Returned by insert when an error occurs.
protected  java.util.HashMap nameHash
           
protected  int nextTypeNumber
           
protected  java.util.ArrayList numberList
           
 
Constructor Summary
TypeTable()
          Default constructor.
TypeTable(int capacity)
          This constructor allows an initial capacity to be specified.
 
Method Summary
 Type get(int typeCode)
          Return the Type corresponding to the typeCode.
 Type get(java.lang.String name)
          Return the Type corresponding to the name.
 int getTypeCode(java.lang.String name)
          Return the typecode corresponding to the type name.
 java.lang.String getTypeName(int typeCode)
          Return the type name corresponding to the typecode.
 int insert(UserType d)
          Adds a user defined type to the typetable.
static void main(java.lang.String[] args)
          For testing and debugging.
 int size()
          Return the number of types stored in the TypeTable.
 java.lang.String toString()
          Return a representation of this object as a nicely formatted String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

invalidTypeCode

public static final int invalidTypeCode
Returned by insert when an error occurs.

See Also:
Constant Field Values

nameHash

protected java.util.HashMap nameHash

numberList

protected java.util.ArrayList numberList

nextTypeNumber

protected int nextTypeNumber
Constructor Detail

TypeTable

public TypeTable()
Default constructor.


TypeTable

public TypeTable(int capacity)
This constructor allows an initial capacity to be specified. It should be more efficient than the default.

Method Detail

insert

public int insert(UserType d)
Adds a user defined type to the typetable. If the insertion is successful, this method will return the typeCode assigned to the new type. Otherwise, an SDBError is generated, and invalidTypeCode is returned. Failure is most likely caused by attempting to insert a type with name that is already being used, and that is not structurally equivalent to the type being inserted.


get

public final Type get(java.lang.String name)
Return the Type corresponding to the name.


get

public final Type get(int typeCode)
Return the Type corresponding to the typeCode.


getTypeCode

public final int getTypeCode(java.lang.String name)
Return the typecode corresponding to the type name.


getTypeName

public final java.lang.String getTypeName(int typeCode)
Return the type name corresponding to the typecode.


size

public final int size()
Return the number of types stored in the TypeTable.


toString

public java.lang.String toString()
Return a representation of this object as a nicely formatted String. This method is meant to be called by the toString method of child classes only.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
For testing and debugging.