at.spardat.xma.serializer
Class AsciiSerializer

java.lang.Object
  extended byat.spardat.xma.serializer.AsciiSerializer
All Implemented Interfaces:
Serializer, XmaOutput
Direct Known Subclasses:
TaggedAsciiSerializer

public class AsciiSerializer
extends java.lang.Object
implements Serializer

Serializer that produces only ascii characters.


Constructor Summary
AsciiSerializer(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
protected  void writeStringEscaped(java.lang.String label, java.lang.String s)
          Writes string by escaping all characters so that the resulting byte array contains only US-ASCII characters.
 void writeStringN(java.lang.String label, java.lang.String s)
          Same as writeString, except that s may be null;
protected  void writeStringNoEscape(java.lang.String s)
          Writes string without escaping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsciiSerializer

public AsciiSerializer(boolean isAtServer,
                       int bufferSize)
Constructor

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

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()

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()

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
See Also:
XmaOutput.writeString(java.lang.String, java.lang.String)

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
See Also:
XmaOutput.writeInt(java.lang.String, int)

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
See Also:
XmaOutput.writeLong(java.lang.String, long)

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
See Also:
XmaOutput.writeShort(java.lang.String, int)

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
See Also:
XmaOutput.writeBoolean(java.lang.String, boolean)

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
See Also:
XmaOutput.writeByte(java.lang.String, int)

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(java.lang.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
See Also:
XmaOutput.writeObject(java.lang.String, java.lang.Object)

writeStringEscaped

protected void writeStringEscaped(java.lang.String label,
                                  java.lang.String s)
Writes string by escaping all characters so that the resulting byte array contains only US-ASCII characters. In this implementation, label is ignored.


writeStringNoEscape

protected void writeStringNoEscape(java.lang.String s)
Writes string without escaping. Therefore, the String must not have meta-characters in it.