megamek.common.net.marshall
Class PacketMarshaller

java.lang.Object
  extended by megamek.common.net.marshall.PacketMarshaller
Direct Known Subclasses:
NativeSerializationMarshaller, XMLMarshaller

public abstract class PacketMarshaller
extends java.lang.Object

Generic marshaller that [un]marshalls the Packet


Field Summary
static int NATIVE_SERIALIZATION_MARSHALING
          Java native serialization marshalling
static int XML_MARSHALING
          XML serialization marshalling
 
Constructor Summary
PacketMarshaller()
           
 
Method Summary
 byte[] marshall(Packet packet)
          Marshalls the packet data into the byte[]
abstract  void marshall(Packet packet, java.io.OutputStream stream)
          Marshalls the packet data into the given OutputStream
 Packet unmarshall(byte[] data)
          Unmarshalls the packet data from the given byte[] array
abstract  Packet unmarshall(java.io.InputStream stream)
          Unmarshalls the packet data from the given InputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NATIVE_SERIALIZATION_MARSHALING

public static final int NATIVE_SERIALIZATION_MARSHALING
Java native serialization marshalling

See Also:
Constant Field Values

XML_MARSHALING

public static final int XML_MARSHALING
XML serialization marshalling

See Also:
Constant Field Values
Constructor Detail

PacketMarshaller

public PacketMarshaller()
Method Detail

marshall

public byte[] marshall(Packet packet)
Marshalls the packet data into the byte[]

Parameters:
packet - packet to marshall
Returns:
marshalled representation of the given Packet

marshall

public abstract void marshall(Packet packet,
                              java.io.OutputStream stream)
                       throws java.lang.Exception
Marshalls the packet data into the given OutputStream

Parameters:
packet - packet to marshall
stream - OutputStream to marshall the Packet to
Throws:
java.lang.Exception

unmarshall

public Packet unmarshall(byte[] data)
Unmarshalls the packet data from the given byte[] array

Parameters:
data - byte[] array to unmarshall the packet from
Returns:
the new Packetunmarshalled from the given byte[] array

unmarshall

public abstract Packet unmarshall(java.io.InputStream stream)
                           throws java.lang.Exception
Unmarshalls the packet data from the given InputStream

Parameters:
stream - InputStream to unmarshall the packet from
Returns:
the new Packetunmarshalled from the given InputStream
Throws:
java.lang.Exception