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 class serializes XML results.

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

Field Summary
 
Fields inherited from class org.basex.data.Serializer
dn, ns
 
Constructor Summary
XMLSerializer(OutputStream o)
          Constructor.
XMLSerializer(OutputStream o, boolean x, boolean p)
          Constructor.
 
Method Summary
 void attribute(byte[] n, byte[] v)
          Serializes an attribute.
 void closeResult()
          Closes a result.
 void cls()
          Closes the serializer.
 void comment(byte[] n)
          Serializes a comment.
 void doctype(byte[] t, byte[] te, byte[] ti)
          Doctype declaration.
 void encoding(String e)
          Sets the encoding and prints a document declaration.
 boolean finished()
          Tests if the serialization was interrupted.
 void item(byte[] b)
          Serializes an item.
 void openResult()
          Starts a result.
 void pi(byte[] n, byte[] v)
          Serializes a processing instruction.
 void text(byte[] b)
          Serializes a text.
 void text(byte[] b, FTPos ftp)
          Serializes a text.
 
Methods inherited from class org.basex.data.Serializer
close, closeElement, emptyElement, emptyElement, level, namespace, node, node, openElement, openElement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSerializer

public XMLSerializer(OutputStream o)
              throws IOException
Constructor.

Parameters:
o - output stream reference
Throws:
IOException - I/O exception

XMLSerializer

public XMLSerializer(OutputStream o,
                     boolean x,
                     boolean p)
              throws IOException
Constructor.

Parameters:
o - output stream reference
x - serialize result as well-formed xml
p - pretty print the result
Throws:
IOException - I/O exception
Method Detail

encoding

public void encoding(String e)
              throws IOException
Sets the encoding and prints a document declaration. Must be called at the beginning of a serialization.

Parameters:
e - encoding
Throws:
IOException - I/O exception

doctype

public void doctype(byte[] t,
                    byte[] te,
                    byte[] ti)
             throws IOException
Doctype declaration.

Parameters:
t - document root element tag
te - external subset
ti - internal subset
Throws:
IOException - IOException

cls

public void cls()
         throws IOException
Description copied from class: Serializer
Closes the serializer.

Throws:
IOException - I/O exception

openResult

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

Specified by:
openResult in class Serializer
Throws:
IOException - I/O exception

closeResult

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

Specified by:
closeResult in class Serializer
Throws:
IOException - I/O exception

attribute

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

Specified by:
attribute in class Serializer
Parameters:
n - name
v - value
Throws:
IOException - I/O exception

text

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

Specified by:
text in class Serializer
Parameters:
b - text bytes
Throws:
IOException - I/O exception

text

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

Specified by:
text in class Serializer
Parameters:
b - text bytes
ftp - full-text positions
Throws:
IOException - I/O exception

comment

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

Specified by:
comment in class Serializer
Parameters:
n - comment
Throws:
IOException - I/O exception

pi

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

Specified by:
pi in class Serializer
Parameters:
n - name
v - value
Throws:
IOException - I/O exception

item

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

Specified by:
item in class Serializer
Parameters:
b - text bytes
Throws:
IOException - I/O 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