dk.vajhoej.record
Class StructWriter

java.lang.Object
  extended by dk.vajhoej.record.StructWriter

public class StructWriter
extends java.lang.Object

Class StructWriter writes a Java object to a byte array as a native struct.


Constructor Summary
StructWriter()
          Construct instance of StructWriter with default buffer size.
StructWriter(int bufsiz)
          Construct instance of StructWriter.
 
Method Summary
 void extend(int newbufsiz)
          Extend capacity.
 byte[] getBytes()
          Get bytes.
 int getLength()
          Get length.
 void write(java.lang.Object o)
          Write.
 void write(java.lang.Object o, InfoProvider lenpvd)
          Write.
 void write(java.lang.Object o, LengthProvider lenpvd)
          Write.
 void write(java.lang.Object o, LengthProvider2 lenpvd)
          Write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructWriter

public StructWriter()
Construct instance of StructWriter with default buffer size.


StructWriter

public StructWriter(int bufsiz)
Construct instance of StructWriter.

Parameters:
bufsiz - size of byte array to write to
Method Detail

write

public void write(java.lang.Object o)
           throws RecordException
Write.

Parameters:
o - object to write
Throws:
RecordException - if impossible to convert between types in class and struct

write

public void write(java.lang.Object o,
                  LengthProvider lenpvd)
           throws RecordException
Write.

Parameters:
o - object to write
lenpvd - supplies length for fields where it is not given (null indicates that it is to be ignored)
Throws:
RecordException - if impossible to convert between types in class and struct

write

public void write(java.lang.Object o,
                  LengthProvider2 lenpvd)
           throws RecordException
Write.

Parameters:
o - object to write
lenpvd - supplies length for fields where it is not given (null indicates that it is to be ignored)
Throws:
RecordException - if impossible to convert between types in class and struct

write

public void write(java.lang.Object o,
                  InfoProvider lenpvd)
           throws RecordException
Write.

Parameters:
o - object to write
lenpvd - supplies various length'es where they are not given (null indicates that it is to be ignored)
Throws:
RecordException - if impossible to convert between types in class and struct

getBytes

public byte[] getBytes()
Get bytes.

Returns:
the resulting byte array

getLength

public int getLength()
Get length.

Returns:
the length

extend

public void extend(int newbufsiz)
Extend capacity.

Parameters:
newbufsiz - new size of byte array to write to