org.basex.data
Class XMLSerializer

java.lang.Object
  extended by org.basex.data.Serializer
      extended by org.basex.data.XMLSerializer

public final class XMLSerializer
extends Serializer

This is an interface for serializing XML results.

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

Field Summary
static java.lang.String INDENT
          Indentation.
 PrintOutput out
          Output stream.
 
Fields inherited from class org.basex.data.Serializer
dn, ns, tags
 
Constructor Summary
XMLSerializer(PrintOutput o)
          Constructor.
XMLSerializer(PrintOutput o, boolean x, boolean p)
          Constructor.
 
Method Summary
 void attribute(byte[] n, byte[] v)
          Serializes an attribute.
 void close(int s)
          Finishes the serializer.
 void closeResult()
          Closes a result.
 void comment(byte[] n)
          Serializes a comment.
static byte[] content(Data data, int p, boolean s)
          Returns the content of the current node.
 boolean finished()
          Tests if the serialization was interrupted.
 void indent(boolean close)
          Prints the text declaration to the output stream.
 void item(byte[] b)
          Serializes an item.
 void open(int size)
          Initializes the serializer.
 void openResult()
          Starts a result.
 void pi(byte[] n, byte[] v)
          Serializes a processing instruction.
 void text(byte[] b)
          Serializes a text.
 
Methods inherited from class org.basex.data.Serializer
closeElement, emptyElement, emptyElement, emptyElement, finishElement, namespace, node, openElement, openElement, pi, startElement, startElement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDENT

public static final java.lang.String INDENT
Indentation.

See Also:
Constant Field Values

out

public final PrintOutput out
Output stream.

Constructor Detail

XMLSerializer

public XMLSerializer(PrintOutput o)
Constructor.

Parameters:
o - output stream

XMLSerializer

public XMLSerializer(PrintOutput o,
                     boolean x,
                     boolean p)
Constructor.

Parameters:
o - output stream
x - xml output
p - pretty printing
Method Detail

open

public void open(int size)
          throws java.io.IOException
Description copied from class: Serializer
Initializes the serializer.

Specified by:
open in class Serializer
Parameters:
size - number of results
Throws:
java.io.IOException - exception

close

public void close(int s)
           throws java.io.IOException
Description copied from class: Serializer
Finishes the serializer.

Specified by:
close in class Serializer
Parameters:
s - number of results
Throws:
java.io.IOException - exception

openResult

public void openResult()
                throws java.io.IOException
Description copied from class: Serializer
Starts a result.

Specified by:
openResult in class Serializer
Throws:
java.io.IOException - exception

closeResult

public void closeResult()
                 throws java.io.IOException
Description copied from class: Serializer
Closes a result.

Specified by:
closeResult in class Serializer
Throws:
java.io.IOException - exception

attribute

public void attribute(byte[] n,
                      byte[] v)
               throws java.io.IOException
Description copied from class: Serializer
Serializes an attribute.

Specified by:
attribute in class Serializer
Parameters:
n - name
v - value
Throws:
java.io.IOException - exception

text

public void text(byte[] b)
          throws java.io.IOException
Description copied from class: Serializer
Serializes a text.

Specified by:
text in class Serializer
Parameters:
b - text bytes
Throws:
java.io.IOException - exception

comment

public void comment(byte[] n)
             throws java.io.IOException
Description copied from class: Serializer
Serializes a comment.

Specified by:
comment in class Serializer
Parameters:
n - comment
Throws:
java.io.IOException - exception

pi

public void pi(byte[] n,
               byte[] v)
        throws java.io.IOException
Description copied from class: Serializer
Serializes a processing instruction.

Specified by:
pi in class Serializer
Parameters:
n - name
v - value
Throws:
java.io.IOException - exception

item

public void item(byte[] b)
          throws java.io.IOException
Description copied from class: Serializer
Serializes an item.

Specified by:
item in class Serializer
Parameters:
b - text bytes
Throws:
java.io.IOException - exception

finished

public boolean finished()
Description copied from class: Serializer
Tests if the serialization was interrupted.

Overrides:
finished in class Serializer
Returns:
result of check

indent

public void indent(boolean close)
            throws java.io.IOException
Prints the text declaration to the output stream.

Parameters:
close - close flag
Throws:
java.io.IOException - in case of problems with the PrintOutput

content

public static byte[] content(Data data,
                             int p,
                             boolean s)
Returns the content of the current node.

Parameters:
data - data reference
p - pre value
s - short representation
Returns:
string representation