Package org.jboss.marshalling
Class ObjectOutputStreamMarshaller
- java.lang.Object
-
- org.jboss.marshalling.ObjectOutputStreamMarshaller
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataOutput
,java.io.Flushable
,java.io.ObjectOutput
,java.lang.AutoCloseable
,ByteOutput
,Marshaller
public class ObjectOutputStreamMarshaller extends java.lang.Object implements Marshaller
A Marshaller which simply wraps an object stream. Useful for retrofitting and testing applications.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.ObjectOutputStream
oos
-
Constructor Summary
Constructors Constructor Description ObjectOutputStreamMarshaller(java.io.ObjectOutputStream oos)
Construct a new instance which wraps the given stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearClassCache()
Discard the class cache.void
clearInstanceCache()
Discard the instance cache.void
close()
void
finish()
Finish marshalling to a stream.void
flush()
void
start(ByteOutput newOutput)
Begin marshalling to a stream.void
write(byte[] buf)
Write all the bytes from the given array to the stream.void
write(byte[] buf, int off, int len)
Write some of the bytes from the given array to the stream.void
write(int val)
Writes to the output stream the eight low-order bits of the argumentb
.void
writeBoolean(boolean val)
void
writeByte(int val)
void
writeBytes(java.lang.String str)
void
writeChar(int val)
void
writeChars(java.lang.String str)
void
writeDouble(double val)
void
writeFloat(float val)
void
writeInt(int val)
void
writeLong(long val)
void
writeObject(java.lang.Object obj)
void
writeObjectUnshared(java.lang.Object obj)
Write an object to the underlying storage or stream as a new instance.void
writeShort(int val)
void
writeUTF(java.lang.String str)
-
-
-
Method Detail
-
writeObject
public void writeObject(java.lang.Object obj) throws java.io.IOException
- Specified by:
writeObject
in interfacejava.io.ObjectOutput
- Throws:
java.io.IOException
-
write
public void write(int val) throws java.io.IOException
Writes to the output stream the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in interfacejava.io.ObjectOutput
- Parameters:
val
- the byte to write- Throws:
java.io.IOException
- if an error occurs
-
write
public void write(byte[] buf) throws java.io.IOException
Write all the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in interfacejava.io.ObjectOutput
- Parameters:
buf
- the byte array- Throws:
java.io.IOException
- if an error occurs
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException
Write some of the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in interfacejava.io.ObjectOutput
- Parameters:
buf
- the byte arrayoff
- the index to start writing fromlen
- the number of bytes to write- Throws:
java.io.IOException
- if an error occurs
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in interfacejava.io.ObjectOutput
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfacejava.io.ObjectOutput
- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean val) throws java.io.IOException
- Specified by:
writeBoolean
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeByte
public void writeByte(int val) throws java.io.IOException
- Specified by:
writeByte
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeShort
public void writeShort(int val) throws java.io.IOException
- Specified by:
writeShort
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChar
public void writeChar(int val) throws java.io.IOException
- Specified by:
writeChar
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeInt
public void writeInt(int val) throws java.io.IOException
- Specified by:
writeInt
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeLong
public void writeLong(long val) throws java.io.IOException
- Specified by:
writeLong
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float val) throws java.io.IOException
- Specified by:
writeFloat
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double val) throws java.io.IOException
- Specified by:
writeDouble
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String str) throws java.io.IOException
- Specified by:
writeBytes
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String str) throws java.io.IOException
- Specified by:
writeChars
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String str) throws java.io.IOException
- Specified by:
writeUTF
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeObjectUnshared
public void writeObjectUnshared(java.lang.Object obj) throws java.io.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:
writeObjectUnshared
in interfaceMarshaller
- Parameters:
obj
- the object to be written- Throws:
java.io.IOException
- if an error occurs
-
start
public void start(ByteOutput newOutput) throws java.io.IOException
Begin marshalling to a stream.- Specified by:
start
in interfaceMarshaller
- Parameters:
newOutput
- the new stream- Throws:
java.io.IOException
- if an error occurs during setup, such as an error writing the header
-
clearInstanceCache
public void clearInstanceCache() throws java.io.IOException
Discard the instance cache. May also discard the class cache in implementations that do not support separated class and instance caches.- Specified by:
clearInstanceCache
in interfaceMarshaller
- Throws:
java.io.IOException
- if an error occurs
-
clearClassCache
public void clearClassCache() throws java.io.IOException
Discard the class cache. Implicitly also discards the instance cache.- Specified by:
clearClassCache
in interfaceMarshaller
- Throws:
java.io.IOException
- if an error occurs
-
finish
public void finish() throws java.io.IOException
Finish 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:
finish
in interfaceMarshaller
- Throws:
java.io.IOException
- if an error occurs
-
-