org.ipdr.common
Class CompositeType

java.lang.Object
  extended by org.ipdr.common.OpenType
      extended by org.ipdr.common.CompositeType
Direct Known Subclasses:
FNFType

public class CompositeType
extends OpenType

This class represents an arbitrary composite data type which adheres to the OpenMBean restrictions.

Once defined, a composite type is immutable, the structure it defines does not change. Significant savings in storage overhead as well as processing can be acheived by using the same instance of CompositeType in all instances of CompositeData which share the same strucutre.


Field Summary
protected  OpenType[] typeList_
          The sequence of types which appear in a data item of this OpenType.
protected  java.util.HashMap typesByName_
          A HashMap to aid in finding the index for a field by its name in this CompositeType.
 
Fields inherited from class org.ipdr.common.OpenType
BOOLEAN_TYPE_CODE, BYTE_TYPE_CODE, derivedType_, description_, DOUBLE_TYPE_CODE, FLOAT_TYPE_CODE, HEX_BINARY_TYPE_CODE, INTEGER_TYPE_CODE, LONG_TYPE_CODE, name_, OBJECT_TYPE_CODE, SHORT_TYPE_CODE, STRING_TYPE_CODE, UNSIGNEDBYTE_TYPE_CODE, UNSIGNEDINT_TYPE_CODE, UNSIGNEDLONG_TYPE_CODE, UNSIGNEDSHORT_TYPE_CODE
 
Constructor Summary
CompositeType(java.lang.String name, OpenType[] types, java.lang.String desc)
          Builds a composite type from the supplied array of types Note that a given CompositeType is immutable.
 
Method Summary
 int getFieldIndex(java.lang.String fieldName)
          Retreives index information for a given named field in the composite type.
 OpenType getFieldType(java.lang.String fieldName)
          Retreives type information for a given named field in the composite type.
 OpenType getType()
          Retreives the details about this type.
 char getTypeCode()
          Retreives simple info about this type being composed.
 OpenType[] getTypeList()
          Retreives the type list which describes the layout of data for this CompositeType.
static void main(java.lang.String[] args)
          Simple demonstration entry point.
 java.lang.String toString()
          Utility method for displaying types.
 
Methods inherited from class org.ipdr.common.OpenType
getDerivedType, getDescription, getName, setDerivedType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

typeList_

protected OpenType[] typeList_
The sequence of types which appear in a data item of this OpenType.


typesByName_

protected java.util.HashMap typesByName_
A HashMap to aid in finding the index for a field by its name in this CompositeType.

Constructor Detail

CompositeType

public CompositeType(java.lang.String name,
                     OpenType[] types,
                     java.lang.String desc)
              throws BadCompositeException
Builds a composite type from the supplied array of types Note that a given CompositeType is immutable. There are no setter methods, hence, you cannot modify the structure of this type once created.

Parameters:
name - Composite Type Name
types - Array of OpenType
desc - Description
Throws:
BadCompositeException - when a problem occurs while building the Composite Type object
Method Detail

getType

public OpenType getType()
Retreives the details about this type. For CompositeType this simply returns itself.

Specified by:
getType in class OpenType
Returns:
The Type

getTypeList

public OpenType[] getTypeList()
Retreives the type list which describes the layout of data for this CompositeType.

The returned array should not be altered.

Returns:
The typeList value

getFieldIndex

public int getFieldIndex(java.lang.String fieldName)
Retreives index information for a given named field in the composite type.

Parameters:
fieldName - The field name
Returns:
The index value of the field

getFieldType

public OpenType getFieldType(java.lang.String fieldName)
Retreives type information for a given named field in the composite type.

Parameters:
fieldName - The field name
Returns:
The Type for the field

getTypeCode

public char getTypeCode()
Retreives simple info about this type being composed.

Specified by:
getTypeCode in class OpenType
Returns:
The TypeCode

toString

public java.lang.String toString()
Utility method for displaying types. Use XML style output.

Overrides:
toString in class java.lang.Object
Returns:
CompositeType in string format

main

public static void main(java.lang.String[] args)
Simple demonstration entry point. Creates a CompositeType with some of the basic types. Then it invokes toString() method on constructed type to display.