Package uk.blankaspect.common.jsonxml
Class JsonGeneratorXml
java.lang.Object
uk.blankaspect.common.jsonxml.JsonGeneratorXml
This class implements a generator that transforms a tree of values that are represented by XML
elements into JSON text. The generator operates in one of several output modes,
which control the way in which whitespace is written between the tokens of the JSON text.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class implements a builder for a JSON generator.static classThis is the abstract base class of an unchecked exception that is associated with an XML element.static classThis class implements an unchecked exception that is thrown in response to an XML element that is a member of an <object> element but has no name attribute.static classThis class implements an unchecked exception that is thrown in response to an unrecognised XML element. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonGeneratorXml.Builderbuilder()Creates and returns a new instance of a builder for a JSON generator.Generates and returns JSON text for the specified XML element in accordance with the properties of this generator: output mode, new line before left bracket parameter, indent increment, maximum line length, printable ASCII only flag.static JsonText.TokenReturns the JSON token that corresponds to the specified XML element.
-
Method Details
-
builder
Creates and returns a new instance of a builder for a JSON generator.- Returns:
- a new instance of a builder for a JSON generator.
-
getToken
Returns the JSON token that corresponds to the specified XML element.- Parameters:
element- the XML element whose corresponding JSON token is sought.- Returns:
- the JSON token that corresponds to
element, ornullif there is no such token.
-
generate
Generates and returns JSON text for the specified XML element in accordance with the properties of this generator:- output mode,
- new line before left bracket parameter,
- indent increment,
- maximum line length,
- printable ASCII only flag.
- Parameters:
element- the XML element for which JSON text will be generated.- Returns:
- the JSON text that was generated for
element. - Throws:
JsonGeneratorXml.UnrecognisedElementException- if any element in the tree whose root iselementdoes not correspond to a JSON value.
-