Package org.jboss.marshalling
Class Marshalling
- java.lang.Object
-
- org.jboss.marshalling.Marshalling
-
public final class Marshalling extends java.lang.ObjectStatic utility methods for simplifying use of marshallers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMarshalling.OptionalDataExceptionCreateActionprivate static classMarshalling.StaticStreamHeader
-
Field Summary
Fields Modifier and Type Field Description private static ClassExternalizerFactoryNULL_CLASS_EXTERNALIZER_FACTORYprivate static ClassTableNULL_CLASS_TABLEprivate static ExternalizerNULL_EXTERNALIZERprivate static ObjectResolverNULL_OBJECT_RESOLVERprivate static ObjectTableNULL_OBJECT_TABLEprivate static StreamHeaderNULL_STREAM_HEADERprivate static Marshalling.OptionalDataExceptionCreateActionOPTIONAL_DATA_EXCEPTION_CREATE_ACTION
-
Constructor Summary
Constructors Modifier Constructor Description privateMarshalling()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ByteInputcreateByteInput(java.io.InputStream inputStream)Create aByteInputwrapper for anInputStream.static ByteInputcreateByteInput(java.nio.ByteBuffer buffer)Create aByteInputwrapper for aByteBuffer.static ByteOutputcreateByteOutput(java.io.OutputStream outputStream)Create aByteOutputwrapper for anOutputStream.static ByteOutputcreateByteOutput(java.nio.ByteBuffer buffer)Create aByteOutputwrapper for aByteBuffer.static java.io.InputStreamcreateInputStream(ByteInput byteInput)Create anInputStreamwrapper for aByteInput.private static java.io.OptionalDataExceptioncreateOptionalDataException()static java.io.OptionalDataExceptioncreateOptionalDataException(boolean eof)Construct a newOptionalDataException.static java.io.OptionalDataExceptioncreateOptionalDataException(int length)Construct a newOptionalDataException.static java.io.OutputStreamcreateOutputStream(ByteOutput byteOutput)Create aOutputStreamwrapper for aByteOutput.static MarshallerFactorygetMarshallerFactory(java.lang.String name)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.static MarshallerFactorygetMarshallerFactory(java.lang.String name, java.lang.ClassLoader classLoader)Get a marshaller factory, by name.static MarshallerFactorygetProvidedMarshallerFactory(java.lang.String name)Get a marshaller factory which is visible to this implementation, by name.private static MarshallerFactoryloadMarshallerFactory(java.util.ServiceLoader<ProviderDescriptor> loader, java.lang.String name)static ClassExternalizerFactorynullClassExternalizerFactory()Return the null class externalizer factory.static ClassTablenullClassTable()Return the null class table instance.static ExternalizernullExternalizer()Get a null externalizer.static ObjectResolvernullObjectResolver()Return the null object resolver.static ObjectTablenullObjectTable()Return the null object instance table.static StreamHeadernullStreamHeader()Get the default stream header producer, which reads and writes no header at all.static voidreadFully(ByteInput input, byte[] dest)Read bytes from aByteInput.static voidreadFully(ByteInput input, byte[] dest, int offs, int len)Read bytes from aByteInput.static StreamHeaderstreamHeader(byte[] headerBytes)Create a stream header that uses the given bytes.
-
-
-
Field Detail
-
NULL_STREAM_HEADER
private static final StreamHeader NULL_STREAM_HEADER
-
NULL_CLASS_EXTERNALIZER_FACTORY
private static final ClassExternalizerFactory NULL_CLASS_EXTERNALIZER_FACTORY
-
NULL_OBJECT_RESOLVER
private static final ObjectResolver NULL_OBJECT_RESOLVER
-
NULL_OBJECT_TABLE
private static final ObjectTable NULL_OBJECT_TABLE
-
NULL_CLASS_TABLE
private static final ClassTable NULL_CLASS_TABLE
-
OPTIONAL_DATA_EXCEPTION_CREATE_ACTION
private static final Marshalling.OptionalDataExceptionCreateAction OPTIONAL_DATA_EXCEPTION_CREATE_ACTION
-
NULL_EXTERNALIZER
private static final Externalizer NULL_EXTERNALIZER
-
-
Method Detail
-
getMarshallerFactory
@Deprecated public static MarshallerFactory getMarshallerFactory(java.lang.String name)
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
nullif no matching factory was found - See Also:
ServiceLoader
-
getMarshallerFactory
public static MarshallerFactory getMarshallerFactory(java.lang.String name, java.lang.ClassLoader classLoader)
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
nullif no matching factory was found - See Also:
ServiceLoader
-
getProvidedMarshallerFactory
public static MarshallerFactory getProvidedMarshallerFactory(java.lang.String name)
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
nullif no matching factory was found
-
loadMarshallerFactory
private static MarshallerFactory loadMarshallerFactory(java.util.ServiceLoader<ProviderDescriptor> loader, java.lang.String name)
-
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 aByteInput. Fully fills in the array.- Parameters:
input- the inputdest- the destination- Throws:
java.io.EOFException- if the end of file is reached before the array is filledjava.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 aByteInput. Fully fills inlenbytes in the array.- Parameters:
input- the inputdest- the destinationoffs- the offset into the arraylen- the number of bytes- Throws:
java.io.EOFException- if the end of file is reached before the array is filledjava.io.IOException- if an I/O error occurs
-
createByteInput
public static ByteInput createByteInput(java.nio.ByteBuffer buffer)
Create aByteInputwrapper for aByteBuffer.- Parameters:
buffer- the byte buffer- Returns:
- the byte input wrapper
-
createByteInput
public static ByteInput createByteInput(java.io.InputStream inputStream)
Create aByteInputwrapper for anInputStream.- Parameters:
inputStream- the input stream- Returns:
- the byte input wrapper
-
createInputStream
public static java.io.InputStream createInputStream(ByteInput byteInput)
Create anInputStreamwrapper for aByteInput.- Parameters:
byteInput- the byte input- Returns:
- the input stream wrapper
-
createByteOutput
public static ByteOutput createByteOutput(java.nio.ByteBuffer buffer)
Create aByteOutputwrapper for aByteBuffer.- Parameters:
buffer- the byte buffer- Returns:
- the byte output wrapper
-
createByteOutput
public static ByteOutput createByteOutput(java.io.OutputStream outputStream)
Create aByteOutputwrapper for anOutputStream.- Parameters:
outputStream- the output stream- Returns:
- the byte output wrapper
-
createOutputStream
public static java.io.OutputStream createOutputStream(ByteOutput byteOutput)
Create aOutputStreamwrapper for aByteOutput.- Parameters:
byteOutput- the byte output- Returns:
- the output stream wrapper
-
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 newOptionalDataException. This method is necssary because there are no public constructors in the API.- Parameters:
eof-trueif 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 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
private static java.io.OptionalDataException createOptionalDataException()
-
nullExternalizer
public static Externalizer nullExternalizer()
Get a null externalizer. Useful in conjunction withObjectTableentries. This externalizer reads and writes no data.- Returns:
- the null externalizer
-
-