org.basex.data
Class Serializer

java.lang.Object
  extended by org.basex.data.Serializer
Direct Known Subclasses:
DOTSerializer, SAXSerializer, XMLSerializer

public abstract class Serializer
extends Object

This is an interface for serializing different kinds of query results.

Author:
Workgroup DBIS, University of Konstanz 2005-10, ISC License, Christian Gruen

Field Summary
 byte[] dn
          Current default namespace.
 Atts ns
          Namespaces.
 
Constructor Summary
Serializer()
           
 
Method Summary
abstract  void attribute(byte[] n, byte[] v)
          Serializes an attribute.
 void close()
          Closes the serializer.
 void closeElement()
          Closes an element.
abstract  void closeResult()
          Closes a result.
abstract  void comment(byte[] b)
          Serializes a comment.
 void emptyElement(byte[] t, byte[]... a)
          Opens and closes an empty element.
 void emptyElement(Expr expr, byte[]... a)
          Opens and closes an empty element.
 boolean finished()
          Tests if the serialization was interrupted.
abstract  void item(byte[] b)
          Serializes an item.
 int level()
          Returns the current level.
 void namespace(byte[] n, byte[] v)
          Serializes a namespace.
 int node(Data data, int pre)
          Serializes a node of the specified data reference.
 int node(Data data, int pre, FTPosData ft)
          Serializes a node of the specified data reference.
 void openElement(byte[] t, byte[]... a)
          Opens an element.
 void openElement(ExprInfo expr, byte[]... a)
          Opens an element.
abstract  void openResult()
          Starts a result.
abstract  void pi(byte[] n, byte[] v)
          Serializes a processing instruction.
abstract  void text(byte[] b)
          Serializes a text.
abstract  void text(byte[] b, FTPos ftp)
          Serializes a text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ns

public final Atts ns
Namespaces.


dn

public byte[] dn
Current default namespace.

Constructor Detail

Serializer

public Serializer()
Method Detail

openResult

public abstract void openResult()
                         throws IOException
Starts a result.

Throws:
IOException - I/O exception

closeResult

public abstract void closeResult()
                          throws IOException
Closes a result.

Throws:
IOException - I/O exception

attribute

public abstract void attribute(byte[] n,
                               byte[] v)
                        throws IOException
Serializes an attribute.

Parameters:
n - name
v - value
Throws:
IOException - I/O exception

text

public abstract void text(byte[] b)
                   throws IOException
Serializes a text.

Parameters:
b - text bytes
Throws:
IOException - I/O exception

text

public abstract void text(byte[] b,
                          FTPos ftp)
                   throws IOException
Serializes a text.

Parameters:
b - text bytes
ftp - full-text positions
Throws:
IOException - I/O exception

comment

public abstract void comment(byte[] b)
                      throws IOException
Serializes a comment.

Parameters:
b - comment
Throws:
IOException - I/O exception

pi

public abstract void pi(byte[] n,
                        byte[] v)
                 throws IOException
Serializes a processing instruction.

Parameters:
n - name
v - value
Throws:
IOException - I/O exception

item

public abstract void item(byte[] b)
                   throws IOException
Serializes an item.

Parameters:
b - text bytes
Throws:
IOException - I/O exception

openElement

public final void openElement(ExprInfo expr,
                              byte[]... a)
                       throws IOException
Opens an element.

Parameters:
expr - expression info
a - attributes
Throws:
IOException - I/O exception

openElement

public final void openElement(byte[] t,
                              byte[]... a)
                       throws IOException
Opens an element.

Parameters:
t - tag
a - attributes
Throws:
IOException - I/O exception

namespace

public final void namespace(byte[] n,
                            byte[] v)
                     throws IOException
Serializes a namespace.

Parameters:
n - name
v - value
Throws:
IOException - I/O exception

emptyElement

public final void emptyElement(byte[] t,
                               byte[]... a)
                        throws IOException
Opens and closes an empty element.

Parameters:
t - tag
a - attributes
Throws:
IOException - I/O exception

emptyElement

public final void emptyElement(Expr expr,
                               byte[]... a)
                        throws IOException
Opens and closes an empty element.

Parameters:
expr - expression info
a - attributes
Throws:
IOException - I/O exception

closeElement

public final void closeElement()
                        throws IOException
Closes an element.

Throws:
IOException - I/O exception

close

public final void close()
                 throws IOException
Closes the serializer.

Throws:
IOException - I/O exception

finished

public boolean finished()
Tests if the serialization was interrupted.

Returns:
result of check

level

public final int level()
Returns the current level.

Returns:
level

node

public final int node(Data data,
                      int pre)
               throws IOException
Serializes a node of the specified data reference.

Parameters:
data - data reference
pre - pre value to start from
Returns:
last pre value
Throws:
IOException - I/O exception

node

public final int node(Data data,
                      int pre,
                      FTPosData ft)
               throws IOException
Serializes a node of the specified data reference.

Parameters:
data - data reference
pre - pre value to start from
ft - full-text data
Returns:
last pre value
Throws:
IOException - I/O exception