Package org.jboss.marshalling
Class Marshalling
java.lang.Object
org.jboss.marshalling.Marshalling
Static utility methods for simplifying use of marshallers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ClassExternalizerFactory
private static final ClassTable
private static final Externalizer
private static final ObjectResolver
private static final ObjectTable
private static final StreamHeader
private static final Marshalling.OptionalDataExceptionCreateAction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteInput
createByteInput
(InputStream inputStream) Create aByteInput
wrapper for anInputStream
.static ByteInput
createByteInput
(ByteBuffer buffer) Create aByteInput
wrapper for aByteBuffer
.static ByteOutput
createByteOutput
(OutputStream outputStream) Create aByteOutput
wrapper for anOutputStream
.static ByteOutput
createByteOutput
(ByteBuffer buffer) Create aByteOutput
wrapper for aByteBuffer
.static InputStream
createInputStream
(ByteInput byteInput) Create anInputStream
wrapper for aByteInput
.private static OptionalDataException
static OptionalDataException
createOptionalDataException
(boolean eof) Construct a newOptionalDataException
.static OptionalDataException
createOptionalDataException
(int length) Construct a newOptionalDataException
.static OutputStream
createOutputStream
(ByteOutput byteOutput) Create aOutputStream
wrapper for aByteOutput
.static MarshallerFactory
getMarshallerFactory
(String name) Deprecated.static MarshallerFactory
getMarshallerFactory
(String name, ClassLoader classLoader) Get a marshaller factory, by name.static MarshallerFactory
Get a marshaller factory which is visible to this implementation, by name.private static MarshallerFactory
loadMarshallerFactory
(ServiceLoader<ProviderDescriptor> loader, String name) static ClassExternalizerFactory
Return the null class externalizer factory.static ClassTable
Return the null class table instance.static Externalizer
Get a null externalizer.static ObjectResolver
Return the null object resolver.static ObjectTable
Return the null object instance table.static StreamHeader
Get the default stream header producer, which reads and writes no header at all.static void
Read bytes from aByteInput
.static void
Read bytes from aByteInput
.static StreamHeader
streamHeader
(byte[] headerBytes) Create a stream header that uses the given bytes.
-
Field Details
-
NULL_STREAM_HEADER
-
NULL_CLASS_EXTERNALIZER_FACTORY
-
NULL_OBJECT_RESOLVER
-
NULL_OBJECT_TABLE
-
NULL_CLASS_TABLE
-
OPTIONAL_DATA_EXCEPTION_CREATE_ACTION
private static final Marshalling.OptionalDataExceptionCreateAction OPTIONAL_DATA_EXCEPTION_CREATE_ACTION -
NULL_EXTERNALIZER
-
-
Constructor Details
-
Marshalling
private Marshalling()
-
-
Method Details
-
getMarshallerFactory
Deprecated.It is recommended that you usegetProvidedMarshallerFactory(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
- the name of the protocol to acquire- Returns:
- the marshaller factory, or
null
if no matching factory was found - See Also:
-
getMarshallerFactory
Get a marshaller factory, by name. Uses the given classloader to locate the factory.- Parameters:
name
- the name of the protocol to acquireclassLoader
- the class loader to use- Returns:
- the marshaller factory, or
null
if no matching factory was found - See Also:
-
getProvidedMarshallerFactory
Get a marshaller factory which is visible to this implementation, by name. Uses the class loader of this API.- Parameters:
name
- the name of the protocol to acquire- Returns:
- the marshaller factory, or
null
if no matching factory was found
-
loadMarshallerFactory
private static MarshallerFactory loadMarshallerFactory(ServiceLoader<ProviderDescriptor> loader, String name) -
nullStreamHeader
Get the default stream header producer, which reads and writes no header at all.- Returns:
- the default stream header producer
-
streamHeader
Create a stream header that uses the given bytes.- Parameters:
headerBytes
- the header bytes- Returns:
- the stream header object
-
readFully
Read bytes from aByteInput
. Fully fills in the array.- Parameters:
input
- the inputdest
- the destination- Throws:
EOFException
- if the end of file is reached before the array is filledIOException
- if an I/O error occurs
-
readFully
Read bytes from aByteInput
. Fully fills inlen
bytes in the array.- Parameters:
input
- the inputdest
- the destinationoffs
- the offset into the arraylen
- the number of bytes- Throws:
EOFException
- if the end of file is reached before the array is filledIOException
- if an I/O error occurs
-
createByteInput
Create aByteInput
wrapper for aByteBuffer
.- Parameters:
buffer
- the byte buffer- Returns:
- the byte input wrapper
-
createByteInput
Create aByteInput
wrapper for anInputStream
.- Parameters:
inputStream
- the input stream- Returns:
- the byte input wrapper
-
createInputStream
Create anInputStream
wrapper for aByteInput
.- Parameters:
byteInput
- the byte input- Returns:
- the input stream wrapper
-
createByteOutput
Create aByteOutput
wrapper for aByteBuffer
.- Parameters:
buffer
- the byte buffer- Returns:
- the byte output wrapper
-
createByteOutput
Create aByteOutput
wrapper for anOutputStream
.- Parameters:
outputStream
- the output stream- Returns:
- the byte output wrapper
-
createOutputStream
Create aOutputStream
wrapper for aByteOutput
.- Parameters:
byteOutput
- the byte output- Returns:
- the output stream wrapper
-
nullClassExternalizerFactory
Return the null class externalizer factory. This instance does not externalize any classes.- Returns:
- the null class externalizer factory
-
nullObjectResolver
Return the null object resolver. This instance does not translate objects in any way.- Returns:
- the null object resolver
-
nullObjectTable
Return the null object instance table. This instance contains no predefined instances.- Returns:
- the null instance table
-
nullClassTable
Return the null class table instance. This instance contains no predefined classes.- Returns:
- the null class table
-
createOptionalDataException
Construct a newOptionalDataException
. 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
Construct a newOptionalDataException
. 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
-
createOptionalDataException
-
nullExternalizer
Get a null externalizer. Useful in conjunction withObjectTable
entries. This externalizer reads and writes no data.- Returns:
- the null externalizer
-
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.