Marshalling API version 1.0.0.Beta1

org.jboss.marshalling
Class AbstractMarshaller

java.lang.Object
  extended by org.jboss.marshalling.AbstractMarshaller
All Implemented Interfaces:
DataOutput, ObjectOutput, 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  ByteOutput byteOutput
          The current byte output.
protected  ClassResolver classResolver
          The configured class resolver.
protected  ClassTable classTable
          The configured class table.
protected  Creator creator
          The configured object creator.
protected  ExternalizerFactory externalizerFactory
          The configured externalizer factory.
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, Configuration configuration)
          Construct a new marshaller instance.
 
Method Summary
 void close()
          
protected abstract  void doWriteObject(Object obj, boolean unshared)
          Implementation of the actual object-writing method.
 void finish()
          Finish marshalling to a stream.
 void flush()
          
 void start(ByteOutput byteOutput)
          Begin marshalling to a stream.
 void write(byte[] bytes)
          
 void write(byte[] bytes, int off, int len)
          
 void write(int v)
          
 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

externalizerFactory

protected final ExternalizerFactory externalizerFactory
The configured 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.


byteOutput

protected ByteOutput byteOutput
The current byte output.

Constructor Detail

AbstractMarshaller

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

Parameters:
marshallerFactory - the marshaller factory
configuration -
Method Detail

write

public void write(int v)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

write

public void write(byte[] bytes)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

write

public void write(byte[] bytes,
                  int off,
                  int len)
           throws IOException

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Throws:
IOException

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

close

public void close()
           throws IOException

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

Marshalling API version 1.0.0.Beta1

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