org.jboss.marshalling
Class Marshalling

java.lang.Object
  extended by org.jboss.marshalling.Marshalling

public final class Marshalling
extends java.lang.Object

Static utility methods for simplfying use of marshallers.


Method Summary
static ByteInput createByteInput(java.nio.ByteBuffer buffer)
          Create a ByteInput wrapper for a ByteBuffer.
static ByteInput createByteInput(java.io.InputStream inputStream)
          Create a ByteInput wrapper for an InputStream.
static ByteOutput createByteOutput(java.nio.ByteBuffer buffer)
          Create a ByteOutput wrapper for a ByteBuffer.
static ByteOutput createByteOutput(java.io.OutputStream outputStream)
          Create a ByteOutput wrapper for an OutputStream.
static java.io.InputStream createInputStream(ByteInput byteInput)
          Create an InputStream wrapper for a ByteInput.
static java.io.OptionalDataException createOptionalDataException(boolean eof)
          Construct a new OptionalDataException.
static java.io.OptionalDataException createOptionalDataException(int length)
          Construct a new OptionalDataException.
static java.io.OutputStream createOutputStream(ByteOutput byteOutput)
          Create a OutputStream wrapper for a ByteOutput.
static ClassExternalizerFactory nullClassExternalizerFactory()
          Return the null class externalizer factory.
static ClassTable nullClassTable()
          Return the null class table instance.
static Externalizer nullExternalizer()
          Get a null externalizer.
static ExternalizerFactory nullExternalizerFactory()
          Deprecated. Use nullClassExternalizerFactory() instead.
static ObjectResolver nullObjectResolver()
          Return the null object resolver.
static ObjectTable nullObjectTable()
          Return the null object instance table.
static StreamHeader nullStreamHeader()
          Get the default stream header producer, which reads and writes no header at all.
static void readFully(ByteInput input, byte[] dest)
          Read bytes from a ByteInput.
static void readFully(ByteInput input, byte[] dest, int offs, int len)
          Read bytes from a ByteInput.
static StreamHeader streamHeader(byte[] headerBytes)
          Create a stream header that uses the given bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nullStreamHeader

public static StreamHeader nullStreamHeader()
Get the default stream header producer, which reads and writes no header at all.

Returns:
the default stream header producer

streamHeader

public static StreamHeader streamHeader(byte[] headerBytes)
Create a stream header that uses the given bytes.

Parameters:
headerBytes - the header bytes
Returns:
the stream header object

readFully

public static void readFully(ByteInput input,
                             byte[] dest)
                      throws java.io.IOException
Read bytes from a ByteInput. Fully fills in the array.

Parameters:
input - the input
dest - the destination
Throws:
java.io.EOFException - if the end of file is reached before the array is filled
java.io.IOException - if an I/O error occurs

readFully

public static void readFully(ByteInput input,
                             byte[] dest,
                             int offs,
                             int len)
                      throws java.io.IOException
Read bytes from a ByteInput. Fully fills in len bytes in the array.

Parameters:
input - the input
dest - the destination
offs - the offset into the array
len - the number of bytes
Throws:
java.io.EOFException - if the end of file is reached before the array is filled
java.io.IOException - if an I/O error occurs

createByteInput

public static ByteInput createByteInput(java.nio.ByteBuffer buffer)
Create a ByteInput wrapper for a ByteBuffer.

Parameters:
buffer - the byte buffer
Returns:
the byte input wrapper

createByteInput

public static ByteInput createByteInput(java.io.InputStream inputStream)
Create a ByteInput wrapper for an InputStream.

Parameters:
inputStream - the input stream
Returns:
the byte input wrapper

createInputStream

public static java.io.InputStream createInputStream(ByteInput byteInput)
Create an InputStream wrapper for a ByteInput.

Parameters:
byteInput - the byte input
Returns:
the input stream wrapper

createByteOutput

public static ByteOutput createByteOutput(java.nio.ByteBuffer buffer)
Create a ByteOutput wrapper for a ByteBuffer.

Parameters:
buffer - the byte buffer
Returns:
the byte output wrapper

createByteOutput

public static ByteOutput createByteOutput(java.io.OutputStream outputStream)
Create a ByteOutput wrapper for an OutputStream.

Parameters:
outputStream - the output stream
Returns:
the byte output wrapper

createOutputStream

public static java.io.OutputStream createOutputStream(ByteOutput byteOutput)
Create a OutputStream wrapper for a ByteOutput.

Parameters:
byteOutput - the byte output
Returns:
the output stream wrapper

nullExternalizerFactory

@Deprecated
public static ExternalizerFactory nullExternalizerFactory()
Deprecated. Use nullClassExternalizerFactory() instead.

Return the null externalizer factory. This instance does not externalize any classes.

Returns:
the null externalizer factory

nullClassExternalizerFactory

public static ClassExternalizerFactory nullClassExternalizerFactory()
Return the null class externalizer factory. This instance does not externalize any classes.

Returns:
the null class externalizer factory

nullObjectResolver

public static ObjectResolver nullObjectResolver()
Return the null object resolver. This instance does not translate objects in any way.

Returns:
the null object resolver

nullObjectTable

public static ObjectTable nullObjectTable()
Return the null object instance table. This instance contains no predefined instances.

Returns:
the null instance table

nullClassTable

public static ClassTable nullClassTable()
Return the null class table instance. This instance contains no predefined classes.

Returns:
the null class table

createOptionalDataException

public static java.io.OptionalDataException createOptionalDataException(boolean eof)
Construct a new OptionalDataException. This method is necssary because there are no public constructors in the API.

Parameters:
eof - true if there is no more data in the buffered part of the stream
Returns:
a new OptionalDataException

createOptionalDataException

public static java.io.OptionalDataException createOptionalDataException(int length)
Construct a new OptionalDataException. This method is necssary because there are no public constructors in the API.

Parameters:
length - the number of bytes of primitive data available to be read in the current buffer
Returns:
a new OptionalDataException

nullExternalizer

public static Externalizer nullExternalizer()
Get a null externalizer. Useful in conjunction with ObjectTable entries. This externalizer reads and writes no data.

Returns:
the null externalizer