step.encoding
Class Encoder

java.lang.Object
  |
  +--step.encoding.Encoder
Direct Known Subclasses:
ArrayEncoder, CreepIntEncoder, DataEncoder, IntEncoder, RecordEncoder, Strategy, StringEncoder

public abstract class Encoder
extends Object

An agent for encoding/decoding objects to/from the STEP binary format.

Encoders encapsulate the information necessary to convert STEP objects to and from a set of bytes. Some encoders apply a standard rule, while others use an adaptive strategy that attempts to minimize the average number of bytes per value.

Encoders are normally instantiated using a factory object.

See Also:
EncodeContext, DecodeContext

Constructor Summary
Encoder(String name, EncoderFactory factory)
           
 
Method Summary
abstract  StepObject decode(DecodeContext context)
          Decode a value.
abstract  void dump(int level)
           
abstract  void encode(StepObject o, EncodeContext context)
          Encode a value.
protected  void eventMessage(String msg)
          Send a text message to this encoder.
 EncoderFactory getFactory()
          Get the factory used to create this encoder.
 String getName()
          Get the name of this encoder.
protected static void indent(int level)
           
protected  String makeFieldName(String fieldName)
          Create an appropriate name for a sub-field encoder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Encoder

public Encoder(String name,
               EncoderFactory factory)
Method Detail

getName

public String getName()
Get the name of this encoder.


getFactory

public EncoderFactory getFactory()
Get the factory used to create this encoder.


makeFieldName

protected String makeFieldName(String fieldName)
Create an appropriate name for a sub-field encoder.


encode

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

Throws:
EncoderException - if the encode operation encountered an error.
IOException - if the encode operation encountered an I/O failure.

decode

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

Throws:
EncoderException - if the decode operation encountered an error.
IOException - if the decode operation encountered an I/O failure.

eventMessage

protected void eventMessage(String msg)
Send a text message to this encoder.

In general, messages are intended for the decoding process.

The default behavior is to ignore the message.

See Also:
EncoderMessageEvent

dump

public abstract void dump(int level)

indent

protected static void indent(int level)