com.googlecode.openbeans
Class XMLEncoder

java.lang.Object
  extended by com.googlecode.openbeans.Encoder
      extended by com.googlecode.openbeans.XMLEncoder

public class XMLEncoder
extends Encoder

XMLEncoder extends Encoder to write out the encoded statements and expressions in XML format. The XML can be read by XMLDecoder later to restore objects and their states.

The API is similar to ObjectOutputStream.


Constructor Summary
XMLEncoder(OutputStream out)
          Construct a XMLEncoder.
 
Method Summary
 void close()
          Call flush() first, then write out XML footer and close the underlying output stream.
 void flush()
          Writes out all objects since last flush to the output stream.
 Object getOwner()
          Returns the owner of this encoder.
 void setOwner(Object owner)
          Sets the owner of this encoder.
 void writeExpression(Expression oldExp)
          Records the expression so that it can be written out later, then calls super implementation.
 void writeObject(Object o)
          Records the object so that it can be written out later, then calls super implementation.
 void writeStatement(Statement oldStat)
          Records the statement so that it can be written out later, then calls super implementation.
 
Methods inherited from class com.googlecode.openbeans.Encoder
get, getExceptionListener, getPersistenceDelegate, remove, setExceptionListener, setPersistenceDelegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLEncoder

public XMLEncoder(OutputStream out)
Construct a XMLEncoder.

Parameters:
out - the output stream where XML is written to
Method Detail

close

public void close()
Call flush() first, then write out XML footer and close the underlying output stream.


flush

public void flush()
Writes out all objects since last flush to the output stream.

The implementation write the XML header first if it has not been written. Then all pending objects since last flush are written.


getOwner

public Object getOwner()
Returns the owner of this encoder.

Returns:
the owner of this encoder

setOwner

public void setOwner(Object owner)
Sets the owner of this encoder.

Parameters:
owner - the owner to set

writeExpression

public void writeExpression(Expression oldExp)
Records the expression so that it can be written out later, then calls super implementation.

Overrides:
writeExpression in class Encoder
Parameters:
oldExp - the expression to write. The target, arguments, and return value of the expression are all old objects.

writeObject

public void writeObject(Object o)
Records the object so that it can be written out later, then calls super implementation.

Overrides:
writeObject in class Encoder
Parameters:
o - the object to encode

writeStatement

public void writeStatement(Statement oldStat)
Records the statement so that it can be written out later, then calls super implementation.

Overrides:
writeStatement in class Encoder
Parameters:
oldStat - a statement of old objects


Copyright © 2013. All Rights Reserved.