JBoss Marshalling 1.3.0.CR9

org.jboss.marshalling
Class ObjectOutputStreamMarshaller

java.lang.Object
  extended by org.jboss.marshalling.ObjectOutputStreamMarshaller
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, 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
ObjectOutputStreamMarshaller(ObjectOutputStream oos)
          Construct a new instance which wraps the given stream.
 
Method Summary
 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 argument b.
 void writeBoolean(boolean val)
          
 void writeByte(int val)
          
 void writeBytes(String str)
          
 void writeChar(int val)
          
 void writeChars(String str)
          
 void writeDouble(double val)
          
 void writeFloat(float val)
          
 void writeInt(int val)
          
 void writeLong(long val)
          
 void writeObject(Object obj)
          
 void writeObjectUnshared(Object obj)
          Write an object to the underlying storage or stream as a new instance.
 void writeShort(int val)
          
 void writeUTF(String str)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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:
writeObject in interface ObjectOutput
Throws:
IOException

write

public void write(int val)
           throws IOException
Writes to the output stream the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ByteOutput
Parameters:
val - the byte to write
Throws:
IOException - if an error occurs

write

public void write(byte[] buf)
           throws IOException
Write all the bytes from the given array to the stream.

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ByteOutput
Parameters:
buf - the byte array
Throws:
IOException - if an error occurs

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws IOException
Write some of the bytes from the given array to the stream.

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ByteOutput
Parameters:
buf - the byte array
off - the index to start writing from
len - the number of bytes to write
Throws:
IOException - if an error occurs

flush

public void flush()
           throws IOException

Specified by:
flush in interface Flushable
Specified by:
flush in interface ObjectOutput
Throws:
IOException

close

public void close()
           throws IOException

Specified by:
close in interface Closeable
Specified by:
close in interface ObjectOutput
Throws:
IOException

writeBoolean

public void writeBoolean(boolean val)
                  throws IOException

Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte

public void writeByte(int val)
               throws IOException

Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeShort

public void writeShort(int val)
                throws IOException

Specified by:
writeShort in interface DataOutput
Throws:
IOException

writeChar

public void writeChar(int val)
               throws IOException

Specified by:
writeChar in interface DataOutput
Throws:
IOException

writeInt

public void writeInt(int val)
              throws IOException

Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong

public void writeLong(long val)
               throws IOException

Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeFloat

public void writeFloat(float val)
                throws IOException

Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeDouble

public void writeDouble(double val)
                 throws IOException

Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeBytes

public void writeBytes(String str)
                throws IOException

Specified by:
writeBytes in interface DataOutput
Throws:
IOException

writeChars

public void writeChars(String str)
                throws IOException

Specified by:
writeChars in interface DataOutput
Throws:
IOException

writeUTF

public void writeUTF(String str)
              throws IOException

Specified by:
writeUTF in interface DataOutput
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:
writeObjectUnshared in interface Marshaller
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:
start in interface Marshaller
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 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 interface Marshaller
Throws:
IOException - if an error occurs

clearClassCache

public void clearClassCache()
                     throws IOException
Discard the class cache. Implicitly also discards the instance cache.

Specified by:
clearClassCache in interface Marshaller
Throws:
IOException - if an error occurs

finish

public void finish()
            throws 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 the Marshaller.start(ByteOutput) method is again invoked.

Specified by:
finish in interface Marshaller
Throws:
IOException - if an error occurs

JBoss Marshalling 1.3.0.CR9

Copyright © 2011 JBoss, a division of Red Hat, Inc.