Qizx/open API

net.axyana.qizxopen.dm
Class TreeEncoder

java.lang.Object
  extended bynet.axyana.qizxopen.dm.TreeEncoder
All Implemented Interfaces:
XMLEventHandler

public class TreeEncoder
extends java.lang.Object
implements XMLEventHandler

Encodes the sub-tree of a Node into binary representation, which can be deserialized by TreeDecoder. This is a Data Model-specific form of serialization.

The root node can be of any kind, with or without parent and siblings, but its deserialized counterpart will always be a top-level node without parent and siblings.


Constructor Summary
TreeEncoder()
           
TreeEncoder(net.axyana.qizxopen.util.io.ByteOutput output)
           
 
Method Summary
 void abort()
          Signals an error in the event flow.
 void definePrefixHints(NSPrefixMapping prefixes)
          Optional: defines a preferred prefix/namespace mapping for serialization.
 void emitAtom(java.lang.Object atom)
           
 void emitAttribute(QName name, java.lang.String value)
           
 void emitComment(java.lang.String contents)
           
 void emitDTD(java.lang.String name2, java.lang.String publicID, java.lang.String systemID)
           
 void emitEndDocument()
           
 void emitEndElement(QName name)
           
 void emitEndMark()
           
 void emitNamespace(java.lang.String prefix, java.lang.String uri)
           
 void emitPI(java.lang.String prefix, java.lang.String contents)
           
 void emitStartDocument()
           
 void emitStartElement(QName name)
           
 void emitText(java.lang.String contents)
           
 void encodeFONI(FONIDocument doc, int nodeId)
          Should not be called directly with a remote node, or the tree traversal will go through the network on each node!
 void evAtom(java.lang.Object value)
          A special atom with any value (serializable).
 void evAtomText(java.lang.String value)
          Text of an atom.
 void evAttribute(QName name, java.lang.String value)
          Adds an attribute on the current element.
 void evComment(java.lang.String value)
          A comment node.
 void evDocumentEnd()
          Ends a document.
 boolean evDocumentStart()
          Starts a document.
 void evDTD(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
          DTD definition.
 void evElementEnd(QName name)
          Ends an element.
 void evElementStart(QName name)
          Starts an element.
 void evNamespace(java.lang.String prefix, java.lang.String uri)
          Adds a namespace node on the current element.
 void evPI(java.lang.String target, java.lang.String value)
          A processing-instruction node.
 void evText(java.lang.String value)
          Text chunk inside an element.
 void noSpace()
          Indicates when evAtomText() must not insert space.
 void reset()
          Resets the state prior to use startDocument() or startElement().
 java.lang.String resolvePrefix(java.lang.String prefix)
          Resolves a prefix to an URI in the context of the current node.
 void terminate()
          Terminates a document or simple subtree.
 void traverse(int flags, FONIDocument document, int nodeId)
          Convenience method: traverses and generates a FONI document using this receiver.
 void traverse(int flags, Node node)
          Convenience method: traverses and generates a subtree into this receiver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeEncoder

public TreeEncoder()

TreeEncoder

public TreeEncoder(net.axyana.qizxopen.util.io.ByteOutput output)
Method Detail

encodeFONI

public void encodeFONI(FONIDocument doc,
                       int nodeId)
                throws DataModelException,
                       java.io.IOException
Should not be called directly with a remote node, or the tree traversal will go through the network on each node!

Throws:
DataModelException
java.io.IOException

emitStartDocument

public void emitStartDocument()
                       throws DataModelException,
                              java.io.IOException
Throws:
DataModelException
java.io.IOException

emitEndDocument

public void emitEndDocument()
                     throws DataModelException,
                            java.io.IOException
Throws:
DataModelException
java.io.IOException

emitEndMark

public void emitEndMark()
                 throws DataModelException,
                        java.io.IOException
Throws:
DataModelException
java.io.IOException

emitDTD

public void emitDTD(java.lang.String name2,
                    java.lang.String publicID,
                    java.lang.String systemID)
             throws DataModelException,
                    java.io.IOException
Throws:
DataModelException
java.io.IOException

emitStartElement

public void emitStartElement(QName name)
                      throws DataModelException,
                             java.io.IOException
Throws:
DataModelException
java.io.IOException

emitEndElement

public void emitEndElement(QName name)
                    throws DataModelException,
                           java.io.IOException
Throws:
DataModelException
java.io.IOException

emitAttribute

public void emitAttribute(QName name,
                          java.lang.String value)
                   throws DataModelException,
                          java.io.IOException
Throws:
DataModelException
java.io.IOException

emitNamespace

public void emitNamespace(java.lang.String prefix,
                          java.lang.String uri)
                   throws DataModelException,
                          java.io.IOException
Throws:
DataModelException
java.io.IOException

emitText

public void emitText(java.lang.String contents)
              throws DataModelException,
                     java.io.IOException
Throws:
DataModelException
java.io.IOException

emitComment

public void emitComment(java.lang.String contents)
                 throws DataModelException,
                        java.io.IOException
Throws:
DataModelException
java.io.IOException

emitPI

public void emitPI(java.lang.String prefix,
                   java.lang.String contents)
            throws DataModelException,
                   java.io.IOException
Throws:
DataModelException
java.io.IOException

emitAtom

public void emitAtom(java.lang.Object atom)
              throws DataModelException,
                     java.io.IOException
Throws:
DataModelException
java.io.IOException

reset

public void reset()
Description copied from interface: XMLEventHandler
Resets the state prior to use startDocument() or startElement().

The general contract is to put the handler in a clean state before event generation, for example clearing the previously built tree in a DOMBuilder.

Specified by:
reset in interface XMLEventHandler

terminate

public void terminate()
               throws DataModelException
Description copied from interface: XMLEventHandler
Terminates a document or simple subtree. May perform consistency checks.

Specified by:
terminate in interface XMLEventHandler
Throws:
DataModelException

abort

public void abort()
           throws DataModelException
Description copied from interface: XMLEventHandler
Signals an error in the event flow.

Specified by:
abort in interface XMLEventHandler
Throws:
DataModelException

evDocumentStart

public boolean evDocumentStart()
                        throws DataModelException
Description copied from interface: XMLEventHandler
Starts a document.

Not called when only a fragment is generated.

Specified by:
evDocumentStart in interface XMLEventHandler
Returns:
true if not inside another node (in which case it should be discarded)
Throws:
DataModelException

evDTD

public void evDTD(java.lang.String name,
                  java.lang.String publicID,
                  java.lang.String systemID)
           throws DataModelException
Description copied from interface: XMLEventHandler
DTD definition.

Specified by:
evDTD in interface XMLEventHandler
Throws:
DataModelException

evDocumentEnd

public void evDocumentEnd()
                   throws DataModelException
Description copied from interface: XMLEventHandler
Ends a document. Must be balanced by a matching startDocument().

Specified by:
evDocumentEnd in interface XMLEventHandler
Throws:
DataModelException

evElementStart

public void evElementStart(QName name)
                    throws DataModelException
Description copied from interface: XMLEventHandler
Starts an element. Must be balanced by a matching endElement().

Specified by:
evElementStart in interface XMLEventHandler
Throws:
DataModelException

evNamespace

public void evNamespace(java.lang.String prefix,
                        java.lang.String uri)
                 throws DataModelException
Description copied from interface: XMLEventHandler
Adds a namespace node on the current element. Must follow startElement and precede any child. May be interleaved with attribute().

Specified by:
evNamespace in interface XMLEventHandler
Throws:
DataModelException

evAttribute

public void evAttribute(QName name,
                        java.lang.String value)
                 throws DataModelException
Description copied from interface: XMLEventHandler
Adds an attribute on the current element. Must follow startElement and precede any child. May be interleaved with namespace(). Supposed to throw an exception if attribute is duplicated.

Specified by:
evAttribute in interface XMLEventHandler
Throws:
DataModelException

evElementEnd

public void evElementEnd(QName name)
                  throws DataModelException
Description copied from interface: XMLEventHandler
Ends an element. Discards prefix/namespace mappings possibly defined by the element.

Specified by:
evElementEnd in interface XMLEventHandler
Throws:
DataModelException

evText

public void evText(java.lang.String value)
            throws DataModelException
Description copied from interface: XMLEventHandler
Text chunk inside an element. No space is generated before or after.

Specified by:
evText in interface XMLEventHandler
Throws:
DataModelException

evAtomText

public void evAtomText(java.lang.String value)
                throws DataModelException
Description copied from interface: XMLEventHandler
Text of an atom. The difference with text() is that a space in requested between two atoms. Hence the argument 'first'.

Specified by:
evAtomText in interface XMLEventHandler
Throws:
DataModelException

noSpace

public void noSpace()
Description copied from interface: XMLEventHandler
Indicates when evAtomText() must not insert space.

Specified by:
noSpace in interface XMLEventHandler

evPI

public void evPI(java.lang.String target,
                 java.lang.String value)
          throws DataModelException
Description copied from interface: XMLEventHandler
A processing-instruction node.

Specified by:
evPI in interface XMLEventHandler
Throws:
DataModelException

evComment

public void evComment(java.lang.String value)
               throws DataModelException
Description copied from interface: XMLEventHandler
A comment node.

Specified by:
evComment in interface XMLEventHandler
Throws:
DataModelException

evAtom

public void evAtom(java.lang.Object value)
            throws DataModelException
Description copied from interface: XMLEventHandler
A special atom with any value (serializable).

Specified by:
evAtom in interface XMLEventHandler
Throws:
DataModelException

traverse

public void traverse(int flags,
                     Node node)
              throws DataModelException
Description copied from interface: XMLEventHandler
Convenience method: traverses and generates a subtree into this receiver.

Specified by:
traverse in interface XMLEventHandler
Parameters:
flags - a combination of flags of StaticContext if true, copy all in-scope namespace nodes (not only those defined on the node itself). A false value is generally used.
Throws:
DataModelException

traverse

public void traverse(int flags,
                     FONIDocument document,
                     int nodeId)
              throws DataModelException
Description copied from interface: XMLEventHandler
Convenience method: traverses and generates a FONI document using this receiver.

Specified by:
traverse in interface XMLEventHandler
Throws:
DataModelException

resolvePrefix

public java.lang.String resolvePrefix(java.lang.String prefix)
Description copied from interface: XMLEventHandler
Resolves a prefix to an URI in the context of the current node.

Specified by:
resolvePrefix in interface XMLEventHandler
Returns:
null if the prefix cannot be resolved.

definePrefixHints

public void definePrefixHints(NSPrefixMapping prefixes)
Description copied from interface: XMLEventHandler
Optional: defines a preferred prefix/namespace mapping for serialization. This table is used when no mapping is in scope in the current context.

Specified by:
definePrefixHints in interface XMLEventHandler

© 2005 Axyana Software