public final class XmlDocumentJsonHandler extends IdleJsonHandler<Document>
XmlDocumentJsonHandler is a JsonHandler that creates a XML
Document that represents the same data as the handled JSON document
using the following rules:
array.object.entry.entry tag with name name.null.boolean.boolean tag with name value .number.number tag with name value.string.string tag with name value .Example:
Input JSON document:
{
"nullValue": null,
"booleanValue": true,
"longValue": -10000,
"doubleValue": 42.23,
"stringValue": "foobar",
"arrayValue": [],
"objectValue": {}
}
Output XML document:
<?xml version="1.0" encoding="UTF-8"?>
<object>
<entry name="nullValue">
<null />
</entry>
<entry name="booleanValue">
<boolean value="true" />
</entry>
<entry name="longValue">
<number value="-10000"/>
</entry>
<entry name="doubleValue">
<number value="42.23" />
</entry>
<entry name="stringValue">
<string value="foobar">
</entry>
<entry name="arrayValue">
<array />
</entry>
<entry name="objectValue">
<object />
</entry>
</object>
| Constructor and Description |
|---|
XmlDocumentJsonHandler()
Creates a new
XmlDocumentJsonHandler using a @link
default
DocumentBuilder created by a
default
DocumentBuilderFactory. |
XmlDocumentJsonHandler(DocumentBuilder documentBuilder)
|
| Modifier and Type | Method and Description |
|---|---|
Document |
getResult()
Returns the calculated result.
|
void |
onArrayBegin()
Called when the parsing of a JSON array started.
|
void |
onArrayEnd()
Called when the parsing of a JSON array ended.
|
void |
onBoolean(boolean value)
Called when the parsing of a JSON object encountered a JSON boolean.
|
void |
onDocumentBegin()
Called when the parsing of a JSON document started.
|
void |
onDocumentEnd()
Called when the parsing of a JSON document ended.
|
void |
onDouble(double value)
Called when the parsing of a JSON object encountered a JSON number, that
represents a decimal value.
|
void |
onLong(long value)
Called when the parsing of a JSON object encountered a JSON number, that
represents an integer value.
|
void |
onName(String name)
Called when the parsing of a JSON object encountered the name for the
next JSON value.
|
void |
onNext()
Called when the parsing of a JSON array or JSON object encountered
another element.
|
void |
onNull()
Called when the parsing of a JSON object encountered a JSON null.
|
void |
onObjectBegin()
Called when the parsing of a JSON object started.
|
void |
onObjectEnd()
Called when the parsing of a JSON object ended.
|
void |
onString(String value)
Called when the parsing of a JSON object encountered a JSON string.
|
checkDouble, checkName, checkStringpublic XmlDocumentJsonHandler()
XmlDocumentJsonHandler using a @link
default
DocumentBuilder created by a
default
DocumentBuilderFactory.public XmlDocumentJsonHandler(DocumentBuilder documentBuilder) throws IllegalArgumentException
documentBuilder - The DocumentBuilder to be used.IllegalArgumentException - If the given DocumentBuilder is null.public void onDocumentBegin()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onDocumentBegin in interface JsonHandler<Document>onDocumentBegin in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onDocumentEnd()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onDocumentEnd in interface JsonHandler<Document>onDocumentEnd in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onArrayBegin()
throws JsonException
JsonHandlerend must eventually be called.
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onArrayBegin in interface JsonHandler<Document>onArrayBegin in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onArrayEnd()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onArrayEnd in interface JsonHandler<Document>onArrayEnd in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onObjectBegin()
throws JsonException
JsonHandlerend must eventually be called.
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onObjectBegin in interface JsonHandler<Document>onObjectBegin in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onObjectEnd()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onObjectEnd in interface JsonHandler<Document>onObjectEnd in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onName(String name) throws JsonIndexException, JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onName in interface JsonHandler<Document>onName in class IdleJsonHandler<Document>name - The name for the next JSON value.JsonIndexException - If the given value is null.JsonException - If the handling failed.public void onNext()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onNext in interface JsonHandler<Document>onNext in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onNull()
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onNull in interface JsonHandler<Document>onNull in class IdleJsonHandler<Document>JsonException - If the handling failed.public void onBoolean(boolean value)
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onBoolean in interface JsonHandler<Document>onBoolean in class IdleJsonHandler<Document>value - The value of the JSON boolean.JsonException - If the handling failed.public void onLong(long value)
throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onLong in interface JsonHandler<Document>onLong in class IdleJsonHandler<Document>value - The value of the JSON number.JsonException - If the handling failed.public void onDouble(double value)
throws JsonValueException,
JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onDouble in interface JsonHandler<Document>onDouble in class IdleJsonHandler<Document>value - The value of the JSON number.JsonValueException - If the given value is not a
number or infinite.JsonException - If the handling failed.public void onString(String value) throws JsonValueException, JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
onString in interface JsonHandler<Document>onString in class IdleJsonHandler<Document>value - The value of the JSON string.JsonValueException - If the given value is null.JsonException - If the handling failed.public Document getResult() throws JsonException
JsonHandler
Implementers should catch any exception that isn't a
JsonException and wrap them in an appropriate
JsonException (e.g. a JsonHandlingException).
getResult in interface JsonHandler<Document>getResult in class IdleJsonHandler<Document>JsonException - If the handling failed.Copyright © 2016–2017 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.