Package org.jboss.marshalling
Class ObjectOutputStreamMarshaller
- java.lang.Object
-
- org.jboss.marshalling.ObjectOutputStreamMarshaller
-
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,ObjectOutput,AutoCloseable,ByteOutput,Marshaller
public class ObjectOutputStreamMarshaller extends Object implements Marshaller
A Marshaller which simply wraps an object stream. Useful for retrofitting and testing applications.
-
-
Constructor Summary
Constructors Constructor Description ObjectOutputStreamMarshaller(ObjectOutputStream oos)Construct a new instance which wraps the given stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearClassCache()Discard the class cache.voidclearInstanceCache()Discard the instance cache.voidclose()voidfinish()Finish marshalling to a stream.voidflush()voidstart(ByteOutput newOutput)Begin marshalling to a stream.voidwrite(byte[] buf)Write all the bytes from the given array to the stream.voidwrite(byte[] buf, int off, int len)Write some of the bytes from the given array to the stream.voidwrite(int val)Writes to the output stream the eight low-order bits of the argumentb.voidwriteBoolean(boolean val)voidwriteByte(int val)voidwriteBytes(String str)voidwriteChar(int val)voidwriteChars(String str)voidwriteDouble(double val)voidwriteFloat(float val)voidwriteInt(int val)voidwriteLong(long val)voidwriteObject(Object obj)voidwriteObjectUnshared(Object obj)Write an object to the underlying storage or stream as a new instance.voidwriteShort(int val)voidwriteUTF(String str)
-
-
-
Constructor Detail
-
ObjectOutputStreamMarshaller
public ObjectOutputStreamMarshaller(ObjectOutputStream oos)
Construct a new instance which wraps the given stream.- Parameters:
oos- the object stream to wrap
-
-
Method Detail
-
writeObject
public void writeObject(Object obj) throws IOException
- Specified by:
writeObjectin interfaceObjectOutput- Throws:
IOException
-
write
public void write(int val) throws IOExceptionWrites to the output stream the eight low-order bits of the argumentb. The 24 high-order bits ofbare ignored.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Parameters:
val- the byte to write- Throws:
IOException- if an error occurs
-
write
public void write(byte[] buf) throws IOExceptionWrite all the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Parameters:
buf- the byte array- Throws:
IOException- if an error occurs
-
write
public void write(byte[] buf, int off, int len) throws IOExceptionWrite some of the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Parameters:
buf- the byte arrayoff- the index to start writing fromlen- the number of bytes to write- Throws:
IOException- if an error occurs
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceObjectOutput- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceObjectOutput- Throws:
IOException
-
writeBoolean
public void writeBoolean(boolean val) throws IOException- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
public void writeByte(int val) throws IOException- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeShort
public void writeShort(int val) throws IOException- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
public void writeChar(int val) throws IOException- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
public void writeInt(int val) throws IOException- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
public void writeLong(long val) throws IOException- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
public void writeFloat(float val) throws IOException- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
public void writeDouble(double val) throws IOException- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeBytes
public void writeBytes(String str) throws IOException
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
public void writeChars(String str) throws IOException
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
public void writeUTF(String str) throws IOException
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
writeObjectUnshared
public void writeObjectUnshared(Object obj) throws IOException
Write an object to the underlying storage or stream as a new instance. The class that implements this interface defines how the object is written.- Specified by:
writeObjectUnsharedin interfaceMarshaller- Parameters:
obj- the object to be written- Throws:
IOException- if an error occurs
-
start
public void start(ByteOutput newOutput) throws IOException
Begin marshalling to a stream.- Specified by:
startin interfaceMarshaller- Parameters:
newOutput- the new stream- Throws:
IOException- if an error occurs during setup, such as an error writing the header
-
clearInstanceCache
public void clearInstanceCache() throws IOExceptionDiscard the instance cache. May also discard the class cache in implementations that do not support separated class and instance caches.- Specified by:
clearInstanceCachein interfaceMarshaller- Throws:
IOException- if an error occurs
-
clearClassCache
public void clearClassCache() throws IOExceptionDiscard the class cache. Implicitly also discards the instance cache.- Specified by:
clearClassCachein interfaceMarshaller- Throws:
IOException- if an error occurs
-
finish
public void finish() throws IOExceptionFinish marshalling to a stream. Any transient class or instance cache is discarded. The stream is released. No further marshalling may be done until theMarshaller.start(ByteOutput)method is again invoked.- Specified by:
finishin interfaceMarshaller- Throws:
IOException- if an error occurs
-
-