it.unimo.dbgroup.momis.XmlTools
Class XmlObjectOutput

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.ObjectOutputStream
          extended byit.unimo.dbgroup.momis.XmlTools.XmlObjectOutput
All Implemented Interfaces:
java.io.DataOutput, java.io.ObjectOutput, java.io.ObjectStreamConstants

public final class XmlObjectOutput
extends java.io.ObjectOutputStream

XmlWriter wrapper that extends ObjectOutputStream.

This class is used by XmlWriter to call custom writeObject(ObjectOutputStream out) methods.

You can also use this class as a stand alone object output serializer. XmlWriter whithout this class would'nt be able to serialize standard java object that use custom writeObject with an ObjectOutputStream as parameter.

This wrapper is provided to extends functionalities of XmlWriter to all java objects. You can think to XmlObjectOutput as a part of XmlWriter or as stand alone object that extends XmlWriter.

Remember that this class is a wrapper, so use XmlWriter if you can, it is more efficient.

For more details see XmlWriter methods.

See Also:
XmlWriter

Nested Class Summary
 
Nested classes inherited from class java.io.ObjectOutputStream
java.io.ObjectOutputStream.PutField
 
Field Summary
private  XmlWriter _wrt
          Reference to the wrapped XmlWriter instance.
 
Fields inherited from class java.io.ObjectOutputStream
 
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
 
Constructor Summary
XmlObjectOutput()
          Create a stand alone wrapper.
XmlObjectOutput(XmlWriter wrt)
          Creates the wrapper and uses the specified XmlWriter object.
 
Method Summary
 void close()
          Does nothing.
 void defaultWriteObject()
          Write the non-static and non-transient fields of the current class as XML child elements.
protected  void drain()
          Does nothing.
protected  boolean enableReplaceObject(boolean enable)
          Not supported.
 void flush()
          Does nothing.
 XmlWriter getWriter()
          Returns the XmlWriter object that this instance is wrapping.
 java.io.ObjectOutputStream.PutField putFields()
          Does nothing, returns null.
protected  java.lang.Object replaceObject(java.lang.Object obj)
          Not supported.
 void reset()
          Does nothing.
 void useProtocolVersion(int version)
          Does nothing.
 void write(byte[] b)
          Write a byte array.
 void write(byte[] b, int off, int len)
          Write leb bytes of a byte array beginning from offset off.
 void write(int data)
          Writes a byte of data.
 void writeBoolean(boolean data)
          Writes a boolean.
 void writeByte(int data)
          Writes a byte.
 void writeBytes(java.lang.String data)
          Writes a data string.
 void writeChar(int data)
          Writes a character.
 void writeChars(java.lang.String data)
          Writes a string.
protected  void writeClassDescriptor(java.io.ObjectStreamClass classdesc)
          Does nothing.
 void writeDouble(double data)
          Writes a 'double'.
 void writeFields()
          Does nothing.
 void writeFloat(float data)
          Writes a float.
 void writeInt(int data)
          Writes an integer.
 void writeLong(long data)
          Writes a long integer.
protected  void writeObjectOverride(java.lang.Object obj)
          Overridden implementation for ObjectOutputStream.writeObject.
 void writeShort(int data)
          Writes a short integer.
protected  void writeStreamHeader()
          Does nothing.
 void writeUTF(java.lang.String s)
          Writes a string.
 
Methods inherited from class java.io.ObjectOutputStream
annotateClass, annotateProxyClass, writeObject, writeUnshared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_wrt

private XmlWriter _wrt
Reference to the wrapped XmlWriter instance.

Constructor Detail

XmlObjectOutput

public XmlObjectOutput(XmlWriter wrt)
                throws java.io.IOException
Creates the wrapper and uses the specified XmlWriter object.

After this constructor returns, the calling method should call XmlWriter.setObjectOutputWrapper(); with the new XmlObjectOutput as parameter to ensure coerence.

If you are creating a stand alone XmlObjectOutput please don't use this construtor, call the no-args constructor instead.

Parameters:
wrt - XmlWriter that must be used.

XmlObjectOutput

public XmlObjectOutput()
                throws java.io.IOException
Create a stand alone wrapper.

Method Detail

writeObjectOverride

protected void writeObjectOverride(java.lang.Object obj)
                            throws java.io.IOException
Overridden implementation for ObjectOutputStream.writeObject.

This method calls XmlWriter.writeObject to accomplish his task.

Throws:
java.io.IOException

replaceObject

protected java.lang.Object replaceObject(java.lang.Object obj)
                                  throws java.io.IOException
Not supported.

Throws:
java.io.IOException

enableReplaceObject

protected boolean enableReplaceObject(boolean enable)
                               throws java.lang.SecurityException
Not supported.

Throws:
java.lang.SecurityException

writeStreamHeader

protected void writeStreamHeader()
                          throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

writeClassDescriptor

protected void writeClassDescriptor(java.io.ObjectStreamClass classdesc)
                             throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

drain

protected void drain()
              throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

getWriter

public XmlWriter getWriter()
Returns the XmlWriter object that this instance is wrapping.


close

public void close()
           throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

writeBoolean

public void writeBoolean(boolean data)
                  throws java.io.IOException
Writes a boolean.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeByte

public void writeByte(int data)
               throws java.io.IOException
Writes a byte.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeShort

public void writeShort(int data)
                throws java.io.IOException
Writes a short integer.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeChar

public void writeChar(int data)
               throws java.io.IOException
Writes a character.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeInt

public void writeInt(int data)
              throws java.io.IOException
Writes an integer.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeLong

public void writeLong(long data)
               throws java.io.IOException
Writes a long integer.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeFloat

public void writeFloat(float data)
                throws java.io.IOException
Writes a float.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeDouble

public void writeDouble(double data)
                 throws java.io.IOException
Writes a 'double'.

Please see XmlWriter methods for more details.

Throws:
java.io.IOException

writeBytes

public void writeBytes(java.lang.String data)
                throws java.io.IOException
Writes a data string.

In this implementation the data string is written in XML as a normal String object but each call to this method will always produce an XML string definition element.
Reference elements are never produced by this method.

Throws:
java.io.IOException

writeChars

public void writeChars(java.lang.String data)
                throws java.io.IOException
Writes a string.

In this implementation the data string is written in XML as a normal String object but each call to this method will always produce an XML string definition element.
Reference elements are never produced by this method.

Throws:
java.io.IOException

writeUTF

public void writeUTF(java.lang.String s)
              throws java.io.IOException
Writes a string.

In this implementation the data string is written in XML as a normal String object but each call to this method will always produce an XML string definition element.
Reference elements are never produced by this method.

Throws:
java.io.IOException

useProtocolVersion

public void useProtocolVersion(int version)
                        throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

defaultWriteObject

public void defaultWriteObject()
                        throws java.io.IOException
Write the non-static and non-transient fields of the current class as XML child elements.

This method calls XmlWriter.defaultWrite() to accomplish his task.

Throws:
java.io.IOException

putFields

public java.io.ObjectOutputStream.PutField putFields()
                                              throws java.io.IOException
Does nothing, returns null.

Throws:
java.io.IOException

writeFields

public void writeFields()
                 throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Does nothing.

Throws:
java.io.IOException

write

public void write(int data)
           throws java.io.IOException
Writes a byte of data.

Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Write a byte array.

This implementation will convert the array into a String and will write it to the DOM tree.

Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write leb bytes of a byte array beginning from offset off.

This implementation will convert the array portion into a String and will write it to the DOM tree.

Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Does nothing.

Throws:
java.io.IOException


Universita' di Modena e Reggio Emilia