org.basex.query.util.json
Class JsonStringConverter

java.lang.Object
  extended by org.basex.query.util.json.JsonStringConverter
All Implemented Interfaces:
JsonHandler

public final class JsonStringConverter
extends java.lang.Object
implements JsonHandler

Writes the parsed JSON file to the given TokenBuilder.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Method Summary
 void booleanLit(boolean b)
          Called when a boolean literal is encountered.
 void closeArg()
          Called when an argument of a constructor function is closed.
 void closeArray()
          Called when a JSON array is closed.
 void closeArrayEntry()
          Called when an entry of a JSON array is closed.
 void closeConstr()
          Called when a constructor function is closed.
 void closeEntry()
          Called when an entry of a JSON object is closed.
 void closeObject()
          Called when a JSON object is closed.
 void nullLit()
          Called when a null literal is encountered.
 void numberLit(byte[] value)
          Called when a number literal is encountered.
 void openArg()
          Called when an argument of a constructor function is opened.
 void openArray()
          Called when a JSON array is opened.
 void openArrayEntry()
          Called when an entry of a JSON array is opened.
 void openConstr(byte[] name)
          Called when a constructor function is opened.
 void openEntry(byte[] key)
          Called when an entry of a JSON object is opened.
 void openObject()
          Called when a JSON object is opened.
static TokenBuilder print(java.lang.String json, JsonParser.Spec spec, boolean un, TokenBuilder tb)
          Writes a pretty-printed representation of the given JSON string to the given builder.
 void stringLit(byte[] value)
          Called when a string literal is encountered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

print

public static TokenBuilder print(java.lang.String json,
                                 JsonParser.Spec spec,
                                 boolean un,
                                 TokenBuilder tb)
                          throws QueryException
Writes a pretty-printed representation of the given JSON string to the given builder.

Parameters:
json - JSON string
spec - JSON spec for parsing
un - unescape flag
tb - token builder
Returns:
the token builder
Throws:
QueryException - parse exception

openObject

public void openObject()
                throws QueryException
Description copied from interface: JsonHandler
Called when a JSON object is opened.

Specified by:
openObject in interface JsonHandler
Throws:
QueryException - query exception

openEntry

public void openEntry(byte[] key)
               throws QueryException
Description copied from interface: JsonHandler
Called when an entry of a JSON object is opened.

Specified by:
openEntry in interface JsonHandler
Parameters:
key - the key of the entry
Throws:
QueryException - query exception

closeEntry

public void closeEntry()
                throws QueryException
Description copied from interface: JsonHandler
Called when an entry of a JSON object is closed.

Specified by:
closeEntry in interface JsonHandler
Throws:
QueryException - query exception

closeObject

public void closeObject()
                 throws QueryException
Description copied from interface: JsonHandler
Called when a JSON object is closed.

Specified by:
closeObject in interface JsonHandler
Throws:
QueryException - query exception

openArray

public void openArray()
               throws QueryException
Description copied from interface: JsonHandler
Called when a JSON array is opened.

Specified by:
openArray in interface JsonHandler
Throws:
QueryException - query exception

openArrayEntry

public void openArrayEntry()
                    throws QueryException
Description copied from interface: JsonHandler
Called when an entry of a JSON array is opened.

Specified by:
openArrayEntry in interface JsonHandler
Throws:
QueryException - query exception

closeArrayEntry

public void closeArrayEntry()
                     throws QueryException
Description copied from interface: JsonHandler
Called when an entry of a JSON array is closed.

Specified by:
closeArrayEntry in interface JsonHandler
Throws:
QueryException - query exception

closeArray

public void closeArray()
                throws QueryException
Description copied from interface: JsonHandler
Called when a JSON array is closed.

Specified by:
closeArray in interface JsonHandler
Throws:
QueryException - query exception

openConstr

public void openConstr(byte[] name)
                throws QueryException
Description copied from interface: JsonHandler
Called when a constructor function is opened.

Specified by:
openConstr in interface JsonHandler
Parameters:
name - name of the constructor
Throws:
QueryException - query exception

openArg

public void openArg()
             throws QueryException
Description copied from interface: JsonHandler
Called when an argument of a constructor function is opened.

Specified by:
openArg in interface JsonHandler
Throws:
QueryException - query exception

closeArg

public void closeArg()
              throws QueryException
Description copied from interface: JsonHandler
Called when an argument of a constructor function is closed.

Specified by:
closeArg in interface JsonHandler
Throws:
QueryException - query exception

closeConstr

public void closeConstr()
                 throws QueryException
Description copied from interface: JsonHandler
Called when a constructor function is closed.

Specified by:
closeConstr in interface JsonHandler
Throws:
QueryException - query exception

numberLit

public void numberLit(byte[] value)
               throws QueryException
Description copied from interface: JsonHandler
Called when a number literal is encountered.

Specified by:
numberLit in interface JsonHandler
Parameters:
value - string representation of the number literal
Throws:
QueryException - query exception

stringLit

public void stringLit(byte[] value)
Description copied from interface: JsonHandler
Called when a string literal is encountered.

Specified by:
stringLit in interface JsonHandler
Parameters:
value - the string

nullLit

public void nullLit()
             throws QueryException
Description copied from interface: JsonHandler
Called when a null literal is encountered.

Specified by:
nullLit in interface JsonHandler
Throws:
QueryException - query exception

booleanLit

public void booleanLit(boolean b)
                throws QueryException
Description copied from interface: JsonHandler
Called when a boolean literal is encountered.

Specified by:
booleanLit in interface JsonHandler
Parameters:
b - the boolean
Throws:
QueryException - query exception