com.fernsroth.easyio.field.handler
Class FieldNumberHandlerBase

java.lang.Object
  extended by com.fernsroth.easyio.field.handler.FieldNumberHandlerBase
All Implemented Interfaces:
FieldHandler
Direct Known Subclasses:
FieldINT64Handler, FieldUINT16Handler, FieldUINT32Handler, FieldUINT64Handler, FieldUINT8Handler

public abstract class FieldNumberHandlerBase
extends java.lang.Object
implements FieldHandler

Author:
Joseph M. Ferner (Near Infinity Corporation)

Constructor Summary
FieldNumberHandlerBase(int bits, boolean unsigned)
          constructor.
 
Method Summary
protected abstract  java.lang.Object createZero()
          creates an object with the value of zero.
protected abstract  java.lang.annotation.Annotation getAnnotation(java.lang.reflect.Field field)
           
protected  int getFieldBits(java.lang.reflect.Field field, java.lang.annotation.Annotation fieldAnnotation)
          gets the number of bits for a given field.
protected abstract  java.lang.Object read(EasyIOInputStream in)
          read data from the input stream.
 void read(EasyIOInputStream in, java.lang.Object obj, java.util.Queue<java.lang.reflect.Field> fieldsQueue)
          reads a field into an object.
protected abstract  void write(EasyIOOutputStream out, java.lang.Object val)
          writes a value to the output stream.
 void write(EasyIOOutputStream out, java.lang.Object obj, java.util.Queue<java.lang.reflect.Field> fieldsQueue)
          writes a field into an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldNumberHandlerBase

public FieldNumberHandlerBase(int bits,
                              boolean unsigned)
constructor.

Parameters:
bits - the number of bits in this number.
unsigned - true, for unsigned. false, if not unsigned.
Method Detail

read

public void read(EasyIOInputStream in,
                 java.lang.Object obj,
                 java.util.Queue<java.lang.reflect.Field> fieldsQueue)
          throws EasyIOException,
                 java.io.IOException
reads a field into an object. It is the responsibility of this function to remove read fields from the fieldsQueue.

Specified by:
read in interface FieldHandler
Parameters:
in - the input stream to read from.
obj - the object to populate.
fieldsQueue - the queue of all fields (field, is head of queue).
Throws:
EasyIOException
java.io.IOException

write

public void write(EasyIOOutputStream out,
                  java.lang.Object obj,
                  java.util.Queue<java.lang.reflect.Field> fieldsQueue)
           throws EasyIOException,
                  java.io.IOException
writes a field into an output stream. It is the responsibility of this function to remove written fields from the fieldsQueue.

Specified by:
write in interface FieldHandler
Parameters:
out - the output stream to write the field to.
obj - the object to read from.
fieldsQueue - the queue of fields to read (field, is head of queue).
Throws:
EasyIOException
java.io.IOException

write

protected abstract void write(EasyIOOutputStream out,
                              java.lang.Object val)
                       throws java.io.IOException
writes a value to the output stream.

Parameters:
out - the output stream to write to.
val - the value to write.
Throws:
java.io.IOException

createZero

protected abstract java.lang.Object createZero()
creates an object with the value of zero.

Returns:
the new zero object.

read

protected abstract java.lang.Object read(EasyIOInputStream in)
                                  throws java.io.IOException
read data from the input stream.

Parameters:
in - the input stream to read from.
Returns:
the read object.
Throws:
java.io.IOException

getFieldBits

protected int getFieldBits(java.lang.reflect.Field field,
                           java.lang.annotation.Annotation fieldAnnotation)
gets the number of bits for a given field.

Parameters:
field - the field to get the number of bits from/
fieldAnnotation - the field annotation.
Returns:
the number of bits.

getAnnotation

protected abstract java.lang.annotation.Annotation getAnnotation(java.lang.reflect.Field field)
Parameters:
field - the field to get the annotation from.
Returns:
the retrieved annotation.


Copyright © 2006 null. All Rights Reserved.