JBoss Marshalling 1.2.1.GA

org.jboss.marshalling
Class AbstractMarshaller

java.lang.Object
  extended by org.jboss.marshalling.AbstractMarshaller
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ByteOutput, Marshaller

public abstract class AbstractMarshaller
extends Object
implements Marshaller

An abstract implementation of the Marshaller interface. Most of the write methods delegate directly to the current data output.


Field Summary
protected  int bufferSize
           
protected  ByteOutput byteOutput
          The current byte output.
protected  ClassExternalizerFactory classExternalizerFactory
          The configured class externalizer factory.
protected  ClassResolver classResolver
          The configured class resolver.
protected  ClassTable classTable
          The configured class table.
protected  int configuredVersion
          The configured version to write.
protected  Creator creator
          The configured object creator.
protected  ExceptionListener exceptionListener
          The configured exception listener.
protected  ObjectResolver objectResolver
          The configured object resolver.
protected  ObjectTable objectTable
          The configured object table.
protected  StreamHeader streamHeader
          The configured stream header.
 
Constructor Summary
protected AbstractMarshaller(AbstractMarshallerFactory marshallerFactory, MarshallingConfiguration configuration)
          Construct a new marshaller instance.
 
Method Summary
 void close()
          
protected  void doStart()
          Perform any marshaller-specific start activity.
protected abstract  void doWriteObject(Object obj, boolean unshared)
          Implementation of the actual object-writing method.
 void finish()
          Finish marshalling to a stream.
 void flush()
          
protected  void shallowFlush()
          This shallow flush will write the internal buffer out to the ByteOutput, but will not flush it.
 void start(ByteOutput byteOutput)
          Begin marshalling to a stream.
 void write(byte[] bytes)
          Write all the bytes from the given array to the stream.
 void write(byte[] bytes, int off, int len)
          Write some of the bytes from the given array to the stream.
 void write(int v)
          Writes to the output stream the eight low-order bits of the argument b.
 void writeBoolean(boolean v)
          
 void writeByte(int v)
          
 void writeBytes(String s)
          
 void writeChar(int v)
          
 void writeChars(String s)
          
 void writeDouble(double v)
          
 void writeFloat(float v)
          
 void writeInt(int v)
          
 void writeLong(long v)
          
 void writeObject(Object obj)
          
 void writeObjectUnshared(Object obj)
          Write an object to the underlying storage or stream as a new instance.
 void writeShort(int v)
          
 void writeUTF(String s)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.marshalling.Marshaller
clearClassCache, clearInstanceCache
 

Field Detail

classExternalizerFactory

protected final ClassExternalizerFactory classExternalizerFactory
The configured class externalizer factory.


streamHeader

protected final StreamHeader streamHeader
The configured stream header.


classResolver

protected final ClassResolver classResolver
The configured class resolver.


objectResolver

protected final ObjectResolver objectResolver
The configured object resolver.


creator

protected final Creator creator
The configured object creator.


classTable

protected final ClassTable classTable
The configured class table.


objectTable

protected final ObjectTable objectTable
The configured object table.


exceptionListener

protected final ExceptionListener exceptionListener
The configured exception listener.


configuredVersion

protected final int configuredVersion
The configured version to write.


byteOutput

protected ByteOutput byteOutput
The current byte output.


bufferSize

protected final int bufferSize
Constructor Detail

AbstractMarshaller

protected AbstractMarshaller(AbstractMarshallerFactory marshallerFactory,
                             MarshallingConfiguration configuration)
Construct a new marshaller instance.

Parameters:
marshallerFactory - the marshaller factory
configuration -
Method Detail

write

public void write(int v)
           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:
v - the byte to write
Throws:
IOException - if an error occurs

write

public void write(byte[] bytes)
           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:
bytes - the byte array
Throws:
IOException - if an error occurs

write

public void write(byte[] bytes,
                  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:
bytes - the byte array
off - the index to start writing from
len - the number of bytes to write
Throws:
IOException - if an error occurs

writeBoolean

public void writeBoolean(boolean v)
                  throws IOException

Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte

public void writeByte(int v)
               throws IOException

Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeShort

public void writeShort(int v)
                throws IOException

Specified by:
writeShort in interface DataOutput
Throws:
IOException

writeChar

public void writeChar(int v)
               throws IOException

Specified by:
writeChar in interface DataOutput
Throws:
IOException

writeInt

public void writeInt(int v)
              throws IOException

Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong

public void writeLong(long v)
               throws IOException

Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeFloat

public void writeFloat(float v)
                throws IOException

Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeDouble

public void writeDouble(double v)
                 throws IOException

Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeBytes

public void writeBytes(String s)
                throws IOException

Specified by:
writeBytes in interface DataOutput
Throws:
IOException

writeChars

public void writeChars(String s)
                throws IOException

Specified by:
writeChars in interface DataOutput
Throws:
IOException

writeUTF

public void writeUTF(String s)
              throws IOException

Specified by:
writeUTF in interface DataOutput
Throws:
IOException

flush

public void flush()
           throws IOException

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

shallowFlush

protected void shallowFlush()
                     throws IOException
This shallow flush will write the internal buffer out to the ByteOutput, but will not flush it.

Throws:
IOException - if an I/O error occurs

close

public void close()
           throws IOException

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

start

public void start(ByteOutput byteOutput)
           throws IOException
Begin marshalling to a stream.

Specified by:
start in interface Marshaller
Parameters:
byteOutput - the new stream
Throws:
IOException - if an error occurs during setup, such as an error writing the header

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

doWriteObject

protected abstract void doWriteObject(Object obj,
                                      boolean unshared)
                               throws IOException
Implementation of the actual object-writing method.

Parameters:
obj - the object to write
unshared - true if the instance is unshared, false if it is shared
Throws:
IOException - if an I/O error occurs

writeObjectUnshared

public final 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

writeObject

public final void writeObject(Object obj)
                       throws IOException

Specified by:
writeObject in interface ObjectOutput
Throws:
IOException

doStart

protected void doStart()
                throws IOException
Perform any marshaller-specific start activity. This implementation simply writes the stream header.

Throws:
IOException - if I/O exception occurs

JBoss Marshalling 1.2.1.GA

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