org.basex.io.serial
Class OutputSerializer

java.lang.Object
  extended by org.basex.io.serial.Serializer
      extended by org.basex.io.serial.OutputSerializer
Direct Known Subclasses:
DOTSerializer, HTMLSerializer, JsonMLSerializer, JSONSerializer, TextSerializer, XHTMLSerializer, XMLSerializer

public abstract class OutputSerializer
extends Serializer

This class serializes data to an output stream.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
protected  boolean content
          Include content type flag.
protected  int ct
          Flag for printing content type.
protected  java.lang.String docsys
          System document type.
protected  boolean escape
          URI escape flag.
protected  boolean html5
          HTML5 flag.
protected  int indents
          Number of spaces to indent.
protected  boolean isep
          Item separator flag (used for formatting).
protected  byte[] nl
          New line.
protected  PrintOutput out
          Output stream.
protected  boolean saomit
          Standalone 'omit' flag.
protected  boolean script
          Script flag.
protected  boolean sep
          Separator flag (used for formatting).
protected  char tab
          Tabular character.
 
Fields inherited from class org.basex.io.serial.Serializer
elem, indent, level, PROPS, tags, undecl
 
Method Summary
protected  void atomic(Item it)
          Serializes an atomic value.
protected  void attribute(byte[] n, byte[] v)
          Serializes an attribute.
 void close()
          Closes the serializer.
protected  void closeResult()
          Closes a result.
protected  void code(int ch)
          Encodes the specified character before printing it.
protected  boolean ct(boolean empty, boolean html)
          Prints the content type declaration.
protected  boolean doctype(byte[] dt)
          Prints the document type declaration.
protected  void finishClose()
          Closes an element.
protected  void finishComment(byte[] n)
          Serializes a comment.
 boolean finished()
          Tests if the serialization was interrupted.
protected  void finishEmpty()
          Closes an empty element.
protected  void finishOpen()
          Finishes an opening element node.
protected  void finishPi(byte[] n, byte[] v)
          Serializes a processing instruction.
protected  void finishText(byte[] b)
          Serializes a text.
protected  void finishText(byte[] b, FTPos ftp)
          Serializes a text.
protected  void hex(int ch)
          Returns a hex entity for the specified character.
protected  void indent()
          Indents the next text.
protected  void openDoc(byte[] n)
          Opens a document.
protected  void openResult()
          Starts a result.
protected  void print(byte[] token)
          Writes a token in the current encoding.
protected  void print(int ch)
          Writes a character in the current encoding.
protected  void print(java.lang.String s)
          Writes a string in the current encoding.
protected  void printChar(int ch)
          Writes a character in the current encoding.
 void reset()
          Resets the serializer (indentation, etc).
protected  void startOpen(byte[] t)
          Starts an element.
 
Methods inherited from class org.basex.io.serial.Serializer
closeDoc, closeElement, get, get, namespace, nsUri, serialize, startElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docsys

protected java.lang.String docsys
System document type.


ct

protected int ct
Flag for printing content type.


sep

protected boolean sep
Separator flag (used for formatting).


isep

protected boolean isep
Item separator flag (used for formatting).


script

protected boolean script
Script flag.


html5

protected final boolean html5
HTML5 flag.


escape

protected final boolean escape
URI escape flag.


saomit

protected final boolean saomit
Standalone 'omit' flag.


content

protected final boolean content
Include content type flag.


nl

protected final byte[] nl
New line.


out

protected final PrintOutput out
Output stream.


indents

protected final int indents
Number of spaces to indent.


tab

protected final char tab
Tabular character.

Method Detail

reset

public final void reset()
Description copied from class: Serializer
Resets the serializer (indentation, etc).

Overrides:
reset in class Serializer

close

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

Overrides:
close in class Serializer
Throws:
java.io.IOException - I/O exception

finished

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

Overrides:
finished in class Serializer
Returns:
result of check

openResult

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

Overrides:
openResult in class Serializer
Throws:
java.io.IOException - I/O exception

closeResult

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

Overrides:
closeResult in class Serializer
Throws:
java.io.IOException - I/O exception

attribute

protected 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 - I/O exception

finishText

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

Specified by:
finishText in class Serializer
Parameters:
b - value
Throws:
java.io.IOException - I/O exception

finishText

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

Overrides:
finishText in class Serializer
Parameters:
b - value
ftp - full-text positions, used for visualization highlighting
Throws:
java.io.IOException - I/O exception

finishComment

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

Specified by:
finishComment in class Serializer
Parameters:
n - value
Throws:
java.io.IOException - I/O exception

finishPi

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

Specified by:
finishPi in class Serializer
Parameters:
n - name
v - value
Throws:
java.io.IOException - I/O exception

atomic

protected void atomic(Item it)
               throws java.io.IOException
Description copied from class: Serializer
Serializes an atomic value.

Specified by:
atomic in class Serializer
Parameters:
it - item
Throws:
java.io.IOException - I/O exception

openDoc

protected void openDoc(byte[] n)
                throws java.io.IOException
Description copied from class: Serializer
Opens a document.

Overrides:
openDoc in class Serializer
Parameters:
n - name
Throws:
java.io.IOException - I/O exception

startOpen

protected void startOpen(byte[] t)
                  throws java.io.IOException
Description copied from class: Serializer
Starts an element.

Specified by:
startOpen in class Serializer
Parameters:
t - tag name
Throws:
java.io.IOException - I/O exception

finishOpen

protected void finishOpen()
                   throws java.io.IOException
Description copied from class: Serializer
Finishes an opening element node.

Specified by:
finishOpen in class Serializer
Throws:
java.io.IOException - I/O exception

finishEmpty

protected void finishEmpty()
                    throws java.io.IOException
Description copied from class: Serializer
Closes an empty element.

Specified by:
finishEmpty in class Serializer
Throws:
java.io.IOException - I/O exception

finishClose

protected void finishClose()
                    throws java.io.IOException
Description copied from class: Serializer
Closes an element.

Specified by:
finishClose in class Serializer
Throws:
java.io.IOException - I/O exception

code

protected void code(int ch)
             throws java.io.IOException
Encodes the specified character before printing it.

Parameters:
ch - character to be encoded and printed
Throws:
java.io.IOException - I/O exception

doctype

protected boolean doctype(byte[] dt)
                   throws java.io.IOException
Prints the document type declaration.

Parameters:
dt - document type, or null for html type
Returns:
true if doctype was added
Throws:
java.io.IOException - I/O exception

indent

protected final void indent()
                     throws java.io.IOException
Indents the next text.

Throws:
java.io.IOException - I/O exception

hex

protected final void hex(int ch)
                  throws java.io.IOException
Returns a hex entity for the specified character.

Parameters:
ch - character
Throws:
java.io.IOException - I/O exception

printChar

protected final void printChar(int ch)
                        throws java.io.IOException
Writes a character in the current encoding. Converts newlines to the operating system default.

Parameters:
ch - character to be printed
Throws:
java.io.IOException - I/O exception

print

protected void print(int ch)
              throws java.io.IOException
Writes a character in the current encoding.

Parameters:
ch - character to be printed
Throws:
java.io.IOException - I/O exception

print

protected final void print(byte[] token)
                    throws java.io.IOException
Writes a token in the current encoding.

Parameters:
token - token to be printed
Throws:
java.io.IOException - I/O exception

print

protected final void print(java.lang.String s)
                    throws java.io.IOException
Writes a string in the current encoding.

Parameters:
s - string to be printed
Throws:
java.io.IOException - I/O exception

ct

protected boolean ct(boolean empty,
                     boolean html)
              throws java.io.IOException
Prints the content type declaration.

Parameters:
empty - empty flag
html - method
Returns:
true if declaration was printed
Throws:
java.io.IOException - I/O exception