org.basex.io.serial
Class JsonMLSerializer

java.lang.Object
  extended by org.basex.io.serial.Serializer
      extended by org.basex.io.serial.OutputSerializer
          extended by org.basex.io.serial.JsonMLSerializer

public final class JsonMLSerializer
extends OutputSerializer

This class serializes data as described in the JsonML specification. JsonML can be used to transform any XML document to JSON and back. Note, however, that namespaces, comments and processing instructions will be discarded in the transformation process. More details are found in the JsonML documentation.

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

Field Summary
 
Fields inherited from class org.basex.io.serial.OutputSerializer
content, ct, docsys, escape, html5, indents, isep, nl, out, saomit, script, sep, tab
 
Fields inherited from class org.basex.io.serial.Serializer
elem, indent, level, PROPS, tags, undecl
 
Constructor Summary
JsonMLSerializer(java.io.OutputStream os, SerializerProp props)
          Constructor.
 
Method Summary
protected  void atomic(Item value)
          Serializes an atomic value.
protected  void attribute(byte[] name, byte[] value)
          Serializes an attribute.
protected  void code(int ch)
          Encodes the specified character before printing it.
protected  void finishClose()
          Closes an element.
protected  void finishComment(byte[] value)
          Serializes a comment.
protected  void finishEmpty()
          Closes an empty element.
protected  void finishOpen()
          Finishes an opening element node.
protected  void finishPi(byte[] name, byte[] value)
          Serializes a processing instruction.
protected  void finishText(byte[] text)
          Serializes a text.
protected  void namespace(byte[] n, byte[] v)
          Serializes a namespace if it has not been serialized by an ancestor yet.
protected  void startOpen(byte[] name)
          Starts an element.
 
Methods inherited from class org.basex.io.serial.OutputSerializer
close, closeResult, ct, doctype, finished, finishText, hex, indent, openDoc, openResult, print, print, print, printChar, reset
 
Methods inherited from class org.basex.io.serial.Serializer
closeDoc, closeElement, get, get, nsUri, serialize, startElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonMLSerializer

public JsonMLSerializer(java.io.OutputStream os,
                        SerializerProp props)
                 throws java.io.IOException
Constructor.

Parameters:
os - output stream reference
props - serialization properties
Throws:
java.io.IOException - I/O exception
Method Detail

startOpen

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

Overrides:
startOpen in class OutputSerializer
Parameters:
name - tag name
Throws:
java.io.IOException - I/O exception

attribute

protected void attribute(byte[] name,
                         byte[] value)
                  throws java.io.IOException
Description copied from class: Serializer
Serializes an attribute.

Overrides:
attribute in class OutputSerializer
Parameters:
name - name
value - value
Throws:
java.io.IOException - I/O exception

namespace

protected void namespace(byte[] n,
                         byte[] v)
                  throws java.io.IOException
Description copied from class: Serializer
Serializes a namespace if it has not been serialized by an ancestor yet.

Overrides:
namespace in class Serializer
Parameters:
n - prefix
v - URI
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.

Overrides:
finishOpen in class OutputSerializer
Throws:
java.io.IOException - I/O exception

finishText

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

Overrides:
finishText in class OutputSerializer
Parameters:
text - value
Throws:
java.io.IOException - I/O exception

finishEmpty

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

Overrides:
finishEmpty in class OutputSerializer
Throws:
java.io.IOException - I/O exception

finishClose

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

Overrides:
finishClose in class OutputSerializer
Throws:
java.io.IOException - I/O exception

code

protected void code(int ch)
             throws java.io.IOException
Description copied from class: OutputSerializer
Encodes the specified character before printing it.

Overrides:
code in class OutputSerializer
Parameters:
ch - character to be encoded and printed
Throws:
java.io.IOException - I/O exception

finishComment

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

Overrides:
finishComment in class OutputSerializer
Parameters:
value - value
Throws:
java.io.IOException - I/O exception

finishPi

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

Overrides:
finishPi in class OutputSerializer
Parameters:
name - name
value - value
Throws:
java.io.IOException - I/O exception

atomic

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

Overrides:
atomic in class OutputSerializer
Parameters:
value - item
Throws:
java.io.IOException - I/O exception