com.partnersoft.io.formats.packrat
Class PackratStructure

java.lang.Object
  extended by com.partnersoft.io.formats.packrat.PackratDatatype
      extended by com.partnersoft.io.formats.packrat.PackratStructure
All Implemented Interfaces:
PackratConstants, java.io.Serializable

public class PackratStructure
extends PackratDatatype

A structure in the Packrat format. A structure is named list of fields; fields can be any valid packrat datatype.

Author:
Paul Reavis Copyright 2002 Partner Software, Inc.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.partnersoft.io.formats.packrat.PackratDatatype
EMPTY_TYPE_ARRAY, sizeParam
 
Fields inherited from interface com.partnersoft.io.formats.packrat.PackratConstants
DATATYPE_ARRAY, DATATYPE_ASSOC, DATATYPE_BLOB, DATATYPE_FLAG_COLLECTION, DATATYPE_FLAG_FIXED, DATATYPE_FLAG_STRUCT, DATATYPE_FLAG_VARIABLE, DATATYPE_FLOAT, DATATYPE_INT, DATATYPE_LIST, DATATYPE_STRING, DATATYPE_STRUCT, DATATYPE_UINT
 
Constructor Summary
PackratStructure()
           
PackratStructure(int sizeParam, java.util.ArrayList subtypeList)
           
PackratStructure(java.lang.String name, int sizeParam, java.util.ArrayList subtypeList)
           
 
Method Summary
 java.lang.Object bytesToObject(ByteBuffer input)
          Convert the given bytes to an appropriate object representation.
 java.util.ArrayList getFields()
           
 int getFixedSizeAmount()
          Override with real fixed size in bytes if isFixedSize() is true.
 PackratDatatype[] getSubtypes()
          Return a list of any subtypes.
 int getTypeCode()
          Return a single-byte code for the type.
 java.lang.String getTypeDescription()
          Return a String description of the data type (e.g.
 boolean isFixedSize()
          If true, datatype requires a fixed number of bytes.
 void objectToBytes(java.lang.Object input, ByteBuffer output)
          Convert the given object to its binary representation.
 void setFields(java.util.ArrayList newFields)
           
 
Methods inherited from class com.partnersoft.io.formats.packrat.PackratDatatype
appendAllTypes, getFullDescription, getName, getSizeParam, objectToByteArray, objectToByteBuffer, objectToBytes, readSize, setName, setSizeParam, toString, writeSize, writeSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackratStructure

public PackratStructure()

PackratStructure

public PackratStructure(int sizeParam,
                        java.util.ArrayList subtypeList)

PackratStructure

public PackratStructure(java.lang.String name,
                        int sizeParam,
                        java.util.ArrayList subtypeList)
Method Detail

getTypeCode

public int getTypeCode()
Description copied from class: PackratDatatype
Return a single-byte code for the type. Must be unique. Valid codes are defined in PackratConstants.

Specified by:
getTypeCode in class PackratDatatype

getTypeDescription

public java.lang.String getTypeDescription()
Description copied from class: PackratDatatype
Return a String description of the data type (e.g. "String", "UInt16", etc.)

Specified by:
getTypeDescription in class PackratDatatype

isFixedSize

public boolean isFixedSize()
Description copied from class: PackratDatatype
If true, datatype requires a fixed number of bytes.

Specified by:
isFixedSize in class PackratDatatype

getFixedSizeAmount

public int getFixedSizeAmount()
Description copied from class: PackratDatatype
Override with real fixed size in bytes if isFixedSize() is true.

Overrides:
getFixedSizeAmount in class PackratDatatype

objectToBytes

public void objectToBytes(java.lang.Object input,
                          ByteBuffer output)
Description copied from class: PackratDatatype
Convert the given object to its binary representation. Throws IllegalArgumentException if it doesn't like the input.

Specified by:
objectToBytes in class PackratDatatype

bytesToObject

public java.lang.Object bytesToObject(ByteBuffer input)
Description copied from class: PackratDatatype
Convert the given bytes to an appropriate object representation. Throws IllegalArgumentException if it doesn't like the input.

Specified by:
bytesToObject in class PackratDatatype

getFields

public java.util.ArrayList getFields()

setFields

public void setFields(java.util.ArrayList newFields)

getSubtypes

public PackratDatatype[] getSubtypes()
Description copied from class: PackratDatatype
Return a list of any subtypes. Defaults to an empty array. Subtypes are any datatypes that are part of this type - for example, fields in a structure or values in a list.

Overrides:
getSubtypes in class PackratDatatype