org.activemq.io.impl
Class AbstractPacketMarshaller

java.lang.Object
  extended by org.activemq.io.impl.AbstractPacketReader
      extended by org.activemq.io.impl.AbstractPacketMarshaller
All Implemented Interfaces:
PacketReader, PacketWriter

public abstract class AbstractPacketMarshaller
extends AbstractPacketReader
implements PacketWriter

Version:
$Revision: 1.1 $

Field Summary
protected  int wireFormatVersion
           
 
Constructor Summary
AbstractPacketMarshaller()
           
 
Method Summary
 boolean canWrite(Packet packet)
           
 int getWireFormatVersion()
           
protected  ActiveMQDestination readDestination(DataInput dataIn)
          Reads a destination from the input stream
 void setWireFormatVersion(int version)
          Set the wire format version
protected  void writeDestination(ActiveMQDestination destination, DataOutput dataOut)
          Writes the given destination to the stream
protected  void writeObject(Object object, DataOutput dataOut)
          Simple (but inefficent) utility method to write an object on to a stream
 void writePacket(Packet p, DataOutput dataOut)
          Write a Packet instance to data output stream
 byte[] writePacketToByteArray(Packet packet)
          Serializes a Packet int a byte array
protected  void writeUTF(String str, DataOutput dataOut)
          simple helper method to ensure null strings are catered for
 
Methods inherited from class org.activemq.io.impl.AbstractPacketReader
buildPacket, canRead, readObject, readPacketFromByteArray, readUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.activemq.io.impl.PacketWriter
getPacketType
 
Methods inherited from interface org.activemq.io.impl.PacketReader
createPacket, getPacketType
 

Field Detail

wireFormatVersion

protected int wireFormatVersion
Constructor Detail

AbstractPacketMarshaller

public AbstractPacketMarshaller()
Method Detail

writeUTF

protected void writeUTF(String str,
                        DataOutput dataOut)
                 throws IOException
simple helper method to ensure null strings are catered for

Parameters:
str -
dataOut -
Throws:
IOException

readDestination

protected ActiveMQDestination readDestination(DataInput dataIn)
                                       throws IOException
Reads a destination from the input stream

Throws:
IOException

writeDestination

protected void writeDestination(ActiveMQDestination destination,
                                DataOutput dataOut)
                         throws IOException
Writes the given destination to the stream

Throws:
IOException

canWrite

public boolean canWrite(Packet packet)
Specified by:
canWrite in interface PacketWriter
Parameters:
packet -
Returns:
true if this PacketWriter can write this type of Packet

writeObject

protected void writeObject(Object object,
                           DataOutput dataOut)
                    throws IOException
Simple (but inefficent) utility method to write an object on to a stream

Parameters:
object -
dataOut -
Throws:
IOException

writePacketToByteArray

public byte[] writePacketToByteArray(Packet packet)
                              throws IOException
Serializes a Packet int a byte array

Specified by:
writePacketToByteArray in interface PacketWriter
Parameters:
packet -
Returns:
the byte[]
Throws:
IOException

writePacket

public void writePacket(Packet p,
                        DataOutput dataOut)
                 throws IOException
Write a Packet instance to data output stream

Specified by:
writePacket in interface PacketWriter
Parameters:
p - the instance to be seralized
dataOut - the output stream
Throws:
IOException - thrown if an error occurs

setWireFormatVersion

public void setWireFormatVersion(int version)
Set the wire format version

Specified by:
setWireFormatVersion in interface PacketReader
Specified by:
setWireFormatVersion in interface PacketWriter
Overrides:
setWireFormatVersion in class AbstractPacketReader
Parameters:
version -

getWireFormatVersion

public int getWireFormatVersion()
Specified by:
getWireFormatVersion in interface PacketReader
Specified by:
getWireFormatVersion in interface PacketWriter
Overrides:
getWireFormatVersion in class AbstractPacketReader
Returns:
the wire format version


Copyright © 2004-2009 Protique, Ltd.. All Rights Reserved.