at.spardat.xma.serializer
Class BinarySerializer

java.lang.Object
  extended byat.spardat.xma.serializer.BinarySerializer
All Implemented Interfaces:
Serializer, XmaOutput

public final class BinarySerializer
extends java.lang.Object
implements Serializer

Serializer implementation that uses the Java-Serialization mechanism


Constructor Summary
BinarySerializer(boolean isAtServer, int bufferSize)
          Constructor
 
Method Summary
 void addHeader()
          Indicates that the result-ByteArray should include a header.
 ByteArray getResult()
          Returns the array of bytes that is the result of the serialization process.
 boolean isAtServer()
          Returns whether this is produced at the server or at the client.
 void writeBoolean(java.lang.String label, boolean b)
          Writes a boolean
 void writeByte(java.lang.String label, int b)
          Write a byte
 void writeInt(java.lang.String label, int i)
          Writes an int
 void writeLong(java.lang.String label, long l)
          Writes a long
 void writeObject(java.lang.String label, java.lang.Object obj)
          Writes an Object.
 void writeSerializedBytes(java.lang.String label, byte[] bytes)
          Write a sequence of bytes that is the output of the same kind of Serializer that is active now, i.e., providing this XmaOutput.
 void writeShort(java.lang.String label, int s)
          Writes a short
 void writeString(java.lang.String label, java.lang.String s)
          Outputs a String
 void writeStringN(java.lang.String label, java.lang.String s)
          Same as writeString, except that s may be null;
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinarySerializer

public BinarySerializer(boolean isAtServer,
                        int bufferSize)
Constructor

Parameters:
isAtServer - is this serializer running at the server side?
bufferSize - initial buffer size
Method Detail

addHeader

public void addHeader()
Description copied from interface: Serializer
Indicates that the result-ByteArray should include a header. Default is to not include a header. Must be called before any data is serialized in this.

Specified by:
addHeader in interface Serializer
See Also:
Serializer.addHeader()

isAtServer

public boolean isAtServer()
Description copied from interface: Serializer
Returns whether this is produced at the server or at the client.

Specified by:
isAtServer in interface Serializer
See Also:
Serializer.isAtServer()

getResult

public ByteArray getResult()
Description copied from interface: Serializer
Returns the array of bytes that is the result of the serialization process.

Specified by:
getResult in interface Serializer
Returns:
object of type ByteArray holding the result
See Also:
Serializer.getResult()

writeString

public void writeString(java.lang.String label,
                        java.lang.String s)
                 throws java.io.IOException
Description copied from interface: XmaOutput
Outputs a String

Specified by:
writeString in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
s - the String; must not be null
Throws:
java.io.IOException

writeStringN

public void writeStringN(java.lang.String label,
                         java.lang.String s)
                  throws java.io.IOException
Description copied from interface: XmaOutput
Same as writeString, except that s may be null;

Specified by:
writeStringN in interface XmaOutput
Throws:
java.io.IOException
See Also:
XmaOutput.writeStringN(java.lang.String, java.lang.String)

writeInt

public void writeInt(java.lang.String label,
                     int i)
              throws java.io.IOException
Description copied from interface: XmaOutput
Writes an int

Specified by:
writeInt in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
i - the int
Throws:
java.io.IOException

writeLong

public void writeLong(java.lang.String label,
                      long l)
               throws java.io.IOException
Description copied from interface: XmaOutput
Writes a long

Specified by:
writeLong in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
l - the long
Throws:
java.io.IOException

writeShort

public void writeShort(java.lang.String label,
                       int s)
                throws java.io.IOException
Description copied from interface: XmaOutput
Writes a short

Specified by:
writeShort in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
s - the short
Throws:
java.io.IOException

writeBoolean

public void writeBoolean(java.lang.String label,
                         boolean b)
                  throws java.io.IOException
Description copied from interface: XmaOutput
Writes a boolean

Specified by:
writeBoolean in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
b - the boolean
Throws:
java.io.IOException

writeByte

public void writeByte(java.lang.String label,
                      int b)
               throws java.io.IOException
Description copied from interface: XmaOutput
Write a byte

Specified by:
writeByte in interface XmaOutput
Parameters:
label - short string that describes what the second parameter means; this string has only descriptive purpose.
b - the byte
Throws:
java.io.IOException

writeSerializedBytes

public void writeSerializedBytes(java.lang.String label,
                                 byte[] bytes)
                          throws java.io.IOException
Description copied from interface: XmaOutput
Write a sequence of bytes that is the output of the same kind of Serializer that is active now, i.e., providing this XmaOutput.

Specified by:
writeSerializedBytes in interface XmaOutput
Parameters:
bytes - sequence of bytes; must not be null
Throws:
java.io.IOException
See Also:
XmaOutput.writeSerializedBytes(String, byte[])

writeObject

public void writeObject(java.lang.String label,
                        java.lang.Object obj)
                 throws java.io.IOException
Description copied from interface: XmaOutput
Writes an Object. Depending on the Serializer implementing XmaOutput, obj needs to implement further interfaces, i.e., java.io.Serializable for binary format.

Specified by:
writeObject in interface XmaOutput
Parameters:
obj - the object to serialize; must not be null
Throws:
java.io.IOException