Top Description Inners Fields Constructors Methods
org.jboss.marshalling

public final Class Marshalling

extends Object
Class Inheritance
Static Imports
java.lang.System.getSecurityManager, java.security.AccessController.doPrivileged

Static utility methods for simplifying use of marshallers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final ClassExternalizerFactory
private static final ClassTable
private static final ObjectResolver
private static final ObjectTable
private static final StreamHeader

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ByteInput

Returns:

the byte input wrapper
createByteInput
(final ByteBuffer
the byte buffer
buffer
)

Create a ByteInput wrapper for a ByteBuffer.

public static ByteInput

Returns:

the byte input wrapper
createByteInput
(final InputStream
the input stream
inputStream
)

Create a ByteInput wrapper for an InputStream.

public static ByteOutput

Returns:

the byte output wrapper
createByteOutput
(final ByteBuffer
the byte buffer
buffer
)

Create a ByteOutput wrapper for a ByteBuffer.

public static ByteOutput

Returns:

the byte output wrapper
createByteOutput
(final OutputStream
the output stream
outputStream
)

Create a ByteOutput wrapper for an OutputStream.

public static InputStream

Returns:

the input stream wrapper
createInputStream
(final ByteInput
the byte input
byteInput
)

Create an InputStream wrapper for a ByteInput.

public static OptionalDataException

Returns:

a new OptionalDataException
createOptionalDataException
(boolean
true if there is no more data in the buffered part of the stream
eof
)

Construct a new java.io.OptionalDataException.

public static OptionalDataException

Returns:

a new OptionalDataException
createOptionalDataException
(int
the number of bytes of primitive data available to be read in the current buffer
length
)

Construct a new java.io.OptionalDataException.

public static OutputStream

Returns:

the output stream wrapper
createOutputStream
(final ByteOutput
the byte output
byteOutput
)

Create a OutputStream wrapper for a ByteOutput.

public static MarshallerFactory

Returns:

the marshaller factory, or null if no matching factory was found
getMarshallerFactory
(final String
the name of the protocol to acquire
name
)

Deprecated It is recommended that you use getProvidedMarshallerFactory(String) instead; using the context class loader to find a marshalling implementation is risky at best as the user may have just about anything on their class path.
Get a marshaller factory, by name.
public static MarshallerFactory

Returns:

the marshaller factory, or null if no matching factory was found
getMarshallerFactory
(final String
the name of the protocol to acquire
name
,
final ClassLoader
the class loader to use
classLoader
)

Get a marshaller factory, by name.

public static MarshallerFactory

Returns:

the marshaller factory, or null if no matching factory was found
getProvidedMarshallerFactory
(final String
the name of the protocol to acquire
name
)

Get a marshaller factory which is visible to this implementation, by name.

private static MarshallerFactory
public static ClassExternalizerFactory

Returns:

the null class externalizer factory
nullClassExternalizerFactory
()

Return the null class externalizer factory.

public static ClassTable

Returns:

the null class table
nullClassTable
()

Return the null class table instance.

public static ObjectResolver

Returns:

the null object resolver
nullObjectResolver
()

Return the null object resolver.

public static ObjectTable

Returns:

the null instance table
nullObjectTable
()

Return the null object instance table.

public static StreamHeader

Returns:

the default stream header producer
nullStreamHeader
()

Get the default stream header producer, which reads and writes no header at all.

public static void
readFully(ByteInput
the input
input
,
byte[]
the destination
dest
)

Read bytes from a ByteInput.

public static void
readFully(ByteInput
the input
input
,
byte[]
the destination
dest
,
int
the offset into the array
offs
,
int
the number of bytes
len
)

Read bytes from a ByteInput.

public static StreamHeader

Returns:

the stream header object
streamHeader
(final byte[]
the header bytes
headerBytes
)

Create a stream header that uses the given bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NULL_CLASS_EXTERNALIZER_FACTORYback to summary
private static final ClassExternalizerFactory NULL_CLASS_EXTERNALIZER_FACTORY
NULL_CLASS_TABLEback to summary
private static final ClassTable NULL_CLASS_TABLE
NULL_OBJECT_RESOLVERback to summary
private static final ObjectResolver NULL_OBJECT_RESOLVER
NULL_OBJECT_TABLEback to summary
private static final ObjectTable NULL_OBJECT_TABLE
NULL_STREAM_HEADERback to summary
private static final StreamHeader NULL_STREAM_HEADER

Constructor Detail

Marshallingback to summary
private Marshalling()

Method Detail

createByteInputback to summary
public static ByteInput createByteInput(final ByteBuffer buffer)

Create a ByteInput wrapper for a ByteBuffer.

Parameters
buffer:ByteBuffer

the byte buffer

Returns:ByteInput

the byte input wrapper

createByteInputback to summary
public static ByteInput createByteInput(final InputStream inputStream)

Create a ByteInput wrapper for an InputStream.

Parameters
inputStream:InputStream

the input stream

Returns:ByteInput

the byte input wrapper

createByteOutputback to summary
public static ByteOutput createByteOutput(final ByteBuffer buffer)

Create a ByteOutput wrapper for a ByteBuffer.

Parameters
buffer:ByteBuffer

the byte buffer

Returns:ByteOutput

the byte output wrapper

createByteOutputback to summary
public static ByteOutput createByteOutput(final OutputStream outputStream)

Create a ByteOutput wrapper for an OutputStream.

Parameters
outputStream:OutputStream

the output stream

Returns:ByteOutput

the byte output wrapper

createInputStreamback to summary
public static InputStream createInputStream(final ByteInput byteInput)

Create an InputStream wrapper for a ByteInput.

Parameters
byteInput:ByteInput

the byte input

Returns:InputStream

the input stream wrapper

createOptionalDataExceptionback to summary
public static OptionalDataException createOptionalDataException(boolean eof)

Construct a new java.io.OptionalDataException. This method is necessary because there are no public constructors in the API.

Parameters
eof:boolean

true if there is no more data in the buffered part of the stream

Returns:OptionalDataException

a new OptionalDataException

createOptionalDataExceptionback to summary
public static OptionalDataException createOptionalDataException(int length)

Construct a new java.io.OptionalDataException. This method is necessary because there are no public constructors in the API.

Parameters
length:int

the number of bytes of primitive data available to be read in the current buffer

Returns:OptionalDataException

a new OptionalDataException

createOutputStreamback to summary
public static OutputStream createOutputStream(final ByteOutput byteOutput)

Create a OutputStream wrapper for a ByteOutput.

Parameters
byteOutput:ByteOutput

the byte output

Returns:OutputStream

the output stream wrapper

getMarshallerFactoryback to summary
public static MarshallerFactory getMarshallerFactory(final String name)

Deprecated

It is recommended that you use getProvidedMarshallerFactory(String) instead; using the context class loader to find a marshalling implementation is risky at best as the user may have just about anything on their class path.

Get a marshaller factory, by name. Uses the thread's current context classloader, if available, to locate the factory.

Parameters
name:String

the name of the protocol to acquire

Returns:MarshallerFactory

the marshaller factory, or null if no matching factory was found

Annotations
@Deprecated
See Also
ServiceLoader
getMarshallerFactoryback to summary
public static MarshallerFactory getMarshallerFactory(final String name, final ClassLoader classLoader)

Get a marshaller factory, by name. Uses the given classloader to locate the factory.

Parameters
name:String

the name of the protocol to acquire

classLoader:ClassLoader

the class loader to use

Returns:MarshallerFactory

the marshaller factory, or null if no matching factory was found

See Also
ServiceLoader
getProvidedMarshallerFactoryback to summary
public static MarshallerFactory getProvidedMarshallerFactory(final String name)

Get a marshaller factory which is visible to this implementation, by name. Uses the class loader of this API.

Parameters
name:String

the name of the protocol to acquire

Returns:MarshallerFactory

the marshaller factory, or null if no matching factory was found

loadMarshallerFactoryback to summary
private static MarshallerFactory loadMarshallerFactory(ServiceLoader<ProviderDescriptor> loader, String name)
nullClassExternalizerFactoryback to summary
public static ClassExternalizerFactory nullClassExternalizerFactory()

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

Returns:ClassExternalizerFactory

the null class externalizer factory

nullClassTableback to summary
public static ClassTable nullClassTable()

Return the null class table instance. This instance contains no predefined classes.

Returns:ClassTable

the null class table

nullObjectResolverback to summary
public static ObjectResolver nullObjectResolver()

Return the null object resolver. This instance does not translate objects in any way.

Returns:ObjectResolver

the null object resolver

nullObjectTableback to summary
public static ObjectTable nullObjectTable()

Return the null object instance table. This instance contains no predefined instances.

Returns:ObjectTable

the null instance table

nullStreamHeaderback to summary
public static StreamHeader nullStreamHeader()

Get the default stream header producer, which reads and writes no header at all.

Returns:StreamHeader

the default stream header producer

readFullyback to summary
public static void readFully(ByteInput input, byte[] dest) throws IOException

Read bytes from a ByteInput. Fully fills in the array.

Parameters
input:ByteInput

the input

dest:byte[]

the destination

Exceptions
IOException:
if an I/O error occurs
EOFException:
if the end of file is reached before the array is filled
readFullyback to summary
public static void readFully(ByteInput input, byte[] dest, int offs, int len) throws IOException

Read bytes from a ByteInput. Fully fills in len bytes in the array.

Parameters
input:ByteInput

the input

dest:byte[]

the destination

offs:int

the offset into the array

len:int

the number of bytes

Exceptions
IOException:
if an I/O error occurs
EOFException:
if the end of file is reached before the array is filled
streamHeaderback to summary
public static StreamHeader streamHeader(final byte[] headerBytes)

Create a stream header that uses the given bytes.

Parameters
headerBytes:byte[]

the header bytes

Returns:StreamHeader

the stream header object

org.jboss.marshalling back to summary

private final Class Marshalling.StaticStreamHeader

extends Object
implements StreamHeader, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.jboss.marshalling.StreamHeader

Field Summary

Modifier and TypeField and Description
private final byte[]
private static final long

Constructor Summary

AccessConstructor and Description
public
StaticStreamHeader(final byte[] bytes)

Method Summary

Modifier and TypeMethod and Description
public void
readHeader(final ByteInput
the stream header
input
)

Implements org.jboss.marshalling.StreamHeader.readHeader.

Read the stream header from the stream.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
writeHeader(final ByteOutput
the stream header
output
)

Implements org.jboss.marshalling.StreamHeader.writeHeader.

Write the stream header to the stream.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

headerBytesback to summary
private final byte[] headerBytes
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StaticStreamHeaderback to summary
public StaticStreamHeader(final byte[] bytes)

Method Detail

readHeaderback to summary
public void readHeader(final ByteInput input) throws IOException

Implements org.jboss.marshalling.StreamHeader.readHeader.

Doc from org.jboss.marshalling.StreamHeader.readHeader.

Read the stream header from the stream.

Parameters
input:ByteInput

the stream header

Exceptions
IOException:
if the header is invalid or an error occurs
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

writeHeaderback to summary
public void writeHeader(final ByteOutput output) throws IOException

Implements org.jboss.marshalling.StreamHeader.writeHeader.

Doc from org.jboss.marshalling.StreamHeader.writeHeader.

Write the stream header to the stream.

Parameters
output:ByteOutput

the stream header

Exceptions
IOException:
if an error occurs