step.encoding
Class RecordEncoder

java.lang.Object
  |
  +--step.encoding.Encoder
        |
        +--step.encoding.RecordEncoder

public class RecordEncoder
extends Encoder

An encoder for STEP record objects.

See Also:
StepRecord, FieldIterator, RecordFactory

Field Summary
static String TYPE_FIELD_NAME
           
 
Constructor Summary
RecordEncoder(String name, EncoderFactory factory)
          Create a "universal" record encoder, capable of encoding all STEP records.
RecordEncoder(String name, RecordDef baseDef, List typeEncAttrs, EncoderFactory factory)
          Create a new encoder for the given record definition.
 
Method Summary
 StepObject decode(DecodeContext context)
          Decode a record.
 void dump(int level)
           
 void encode(StepObject o, EncodeContext context)
          Encode a record.
 
Methods inherited from class step.encoding.Encoder
eventMessage, getFactory, getName, indent, makeFieldName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_FIELD_NAME

public static final String TYPE_FIELD_NAME
See Also:
Constant Field Values
Constructor Detail

RecordEncoder

public RecordEncoder(String name,
                     EncoderFactory factory)
Create a "universal" record encoder, capable of encoding all STEP records.

Types are tagged with their type name, encoded the IdentifierStrategy.


RecordEncoder

public RecordEncoder(String name,
                     RecordDef baseDef,
                     List typeEncAttrs,
                     EncoderFactory factory)
Create a new encoder for the given record definition.

This encoder will support the given record type and all its sub-types.

Parameters:
name - the name of this encoder.
baseDef - the root type to allow through this encoder.
typeEncAttrs - attributes for the type tag encoder.
factory - the EncoderFactory used to create this encoder.
Throws:
IllegalArgumentException - if the given base type may not be used. NOTE: The internal records (such as MetaRecord or the EncoderEvent records) are not permitted because the require subtle bootstrapping.
Method Detail

encode

public void encode(StepObject o,
                   EncodeContext context)
            throws EncoderException,
                   IOException
Encode a record.

Specified by:
encode in class Encoder
Throws:
EncoderException - if the type is not allowed by this encoder.
IOException - if the encode operation encountered an I/O failure.

decode

public StepObject decode(DecodeContext context)
                  throws EncoderException,
                         IOException
Decode a record.

Specified by:
decode in class Encoder
Throws:
RecordDefNotFoundException - if a definition for the type could not be loaded.
IOException - if the decode operation encountered an I/O failure.
EncoderException - if the decode operation encountered an error.

dump

public void dump(int level)
Specified by:
dump in class Encoder