public class JsonHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.function.IntPredicate |
charChecker |
boolean |
escape |
Constructor and Description |
---|
JsonHandler() |
Modifier and Type | Method and Description |
---|---|
void |
endArray()
Close the current array
|
void |
endMap()
Close the current object/map
|
XPathContext |
getContext() |
Sequence<?> |
getResult() |
protected void |
handleInvalidCharacters(FastStringBuffer buffer)
Deal with invalid characters in the JSON string
|
protected void |
markAsEscaped(java.lang.CharSequence escaped,
boolean isKey) |
java.lang.String |
reEscape(java.lang.String val)
Optionally apply escaping or unescaping to a value.
|
void |
setContext(XPathContext context) |
void |
setFallbackFunction(java.util.Map<java.lang.String,Sequence<?>> options,
XPathContext context) |
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 |
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
|
public boolean escape
protected java.util.function.IntPredicate charChecker
public void setContext(XPathContext context)
public XPathContext getContext()
public Sequence<?> getResult() throws XPathException
XPathException
public boolean setKey(java.lang.String unEscaped, java.lang.String reEscaped)
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 void startArray() throws XPathException
XPathException
- if any error occurspublic void endArray() throws XPathException
XPathException
- if any error occurspublic void startMap() throws XPathException
XPathException
- if any error occurspublic void endMap() throws XPathException
XPathException
- if any error occurspublic void writeNumeric(java.lang.String asString, double asDouble) throws XPathException
asString
- the string representation of the valueasDouble
- the double representation of the valueXPathException
- if any error occurspublic void writeString(java.lang.String val) throws XPathException
val
- The string to be written (which may or may not contain JSON escape sequences, according to the
options that were set)XPathException
- if any error occurspublic java.lang.String reEscape(java.lang.String val) throws XPathException
val
- the string to be escaped or unEscapedXPathException
public void writeBoolean(boolean value) throws XPathException
value
- the boolean value to be writtenXPathException
- if any error occurspublic void writeNull() throws XPathException
XPathException
- if any error occursprotected void handleInvalidCharacters(FastStringBuffer buffer) throws XPathException
buffer
- the JSON stringXPathException
- if any error occursprotected void markAsEscaped(java.lang.CharSequence escaped, boolean isKey) throws XPathException
XPathException
public void setFallbackFunction(java.util.Map<java.lang.String,Sequence<?>> options, XPathContext context) throws XPathException
XPathException
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.