public class JsonHandlerXML extends JsonHandler
Modifier and Type | Field and Description |
---|---|
boolean |
allowAnyTopLevel |
boolean |
checkForDuplicates |
static java.lang.String |
JSON_NS |
boolean |
liberal |
static java.lang.String |
PREFIX |
static java.lang.String |
SCHEMA_URI |
java.util.HashMap<java.lang.String,SchemaType> |
types |
boolean |
validate |
charChecker, escape
Constructor and Description |
---|
JsonHandlerXML(XPathContext context,
java.lang.String staticBaseUri,
int flags)
Make the handler to construct the XML tree representation for JSON
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
containsEscape(java.lang.String literal)
Check whether a string contains an escape sequence
|
void |
endArray()
Close the current array
|
void |
endMap()
Close the current object/map
|
Item |
getResult()
Return the complete parsed result
|
protected void |
markAsEscaped(java.lang.CharSequence escaped,
boolean isKey) |
boolean |
setKey(java.lang.String unEscaped,
java.lang.String reEscaped)
Set the key to be written for the next entry in an object/map
|
void |
setType(java.lang.String name,
SchemaType st)
Record a SchemaType for a particular name
|
void |
startArray()
Open a new array
|
void |
startMap()
Start a new object/map
|
void |
writeBoolean(boolean value)
Write a boolean value
|
void |
writeNull()
Write a null value
|
void |
writeNumeric(java.lang.String asString,
double asDouble)
Write a numeric value
|
void |
writeString(java.lang.String val)
Write a string value
|
getContext, handleInvalidCharacters, reEscape, setContext, setFallbackFunction
public boolean allowAnyTopLevel
public boolean liberal
public boolean validate
public boolean checkForDuplicates
public static final java.lang.String SCHEMA_URI
public static final java.lang.String JSON_NS
public static final java.lang.String PREFIX
public java.util.HashMap<java.lang.String,SchemaType> types
public JsonHandlerXML(XPathContext context, java.lang.String staticBaseUri, int flags) throws XPathException
context
- the context in which the result tree is to be builtstaticBaseUri
- the static base URI, used for the base URI of the constructed treeflags
- flags indicating the chosen optionsXPathException
- if initialization fails, for example because of problems loading the schemapublic void setType(java.lang.String name, SchemaType st)
name
- the name to be used for the type, e.g. "arrayType"st
- the schema type to be used for typing such entitiespublic boolean setKey(java.lang.String unEscaped, java.lang.String reEscaped)
setKey
in class JsonHandler
unEscaped
- the key for the entry (null implies no key) in unescaped form (backslashes,
if present, do not signal an escape sequence)reEscaped
- the key for the entry (null implies no key) in reescaped form. In this form
special characters are represented as backslash-escaped sequences if the escape
option is yes; if escape=no, the reEscaped form is the same as the unEscaped form.public Item getResult() throws XPathException
getResult
in class JsonHandler
XPathException
protected boolean containsEscape(java.lang.String literal)
literal
- the string to be checkedpublic void startArray() throws XPathException
startArray
in class JsonHandler
XPathException
- if a dynamic error occurspublic void endArray() throws XPathException
endArray
in class JsonHandler
XPathException
- if a dynamic error occurspublic void startMap() throws XPathException
startMap
in class JsonHandler
XPathException
- if a dynamic error occurspublic void endMap() throws XPathException
endMap
in class JsonHandler
XPathException
- if a dynamic error occurspublic void writeNumeric(java.lang.String asString, double asDouble) throws XPathException
writeNumeric
in class JsonHandler
asString
- the string representation of the valueasDouble
- the double representation of the valueXPathException
- if a dynamic error occurspublic void writeString(java.lang.String val) throws XPathException
writeString
in class JsonHandler
val
- the string to be written. This will be in unescaped form if unescaping was requested
in the flags, otherwise it may contain JSON escape sequencesXPathException
- if a dynamic error occursprotected void markAsEscaped(java.lang.CharSequence escaped, boolean isKey) throws XPathException
markAsEscaped
in class JsonHandler
XPathException
public void writeBoolean(boolean value) throws XPathException
writeBoolean
in class JsonHandler
value
- the boolean value to be writtenXPathException
- if a dynamic error occurspublic void writeNull() throws XPathException
writeNull
in class JsonHandler
XPathException
- if a dynamic error occursCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.