public class XMLParserConfiguration extends ParserConfiguration
Modifier and Type | Field and Description |
---|---|
static XMLParserConfiguration |
KEEP_STRINGS
Original configuration of the XML Parser except that values are kept as strings.
|
static XMLParserConfiguration |
ORIGINAL
Original Configuration of the XML Parser.
|
DEFAULT_MAXIMUM_NESTING_DEPTH, keepStrings, maxNestingDepth, UNDEFINED_MAXIMUM_NESTING_DEPTH
Constructor and Description |
---|
XMLParserConfiguration()
Default parser configuration.
|
XMLParserConfiguration(boolean keepStrings)
Deprecated.
This constructor has been deprecated in favor of using the new builder
pattern for the configuration.
This constructor may be removed in a future release.
|
XMLParserConfiguration(boolean keepStrings,
String cDataTagName)
Deprecated.
This constructor has been deprecated in favor of using the new builder
pattern for the configuration.
This constructor may be removed in a future release.
|
XMLParserConfiguration(boolean keepStrings,
String cDataTagName,
boolean convertNilAttributeToNull)
Deprecated.
This constructor has been deprecated in favor of using the new builder
pattern for the configuration.
This constructor may be removed or marked private in a future release.
|
XMLParserConfiguration(String cDataTagName)
Deprecated.
This constructor has been deprecated in favor of using the new builder
pattern for the configuration.
This constructor may be removed in a future release.
|
Modifier and Type | Method and Description |
---|---|
protected XMLParserConfiguration |
clone()
Provides a new instance of the same configuration.
|
String |
getcDataTagName()
The name of the key in a JSON Object that indicates a CDATA section.
|
Set<String> |
getForceList()
When parsing the XML into JSON, specifies that tags that will be converted to arrays
in this configuration
Set<String> to parse the provided tags' values as arrays |
Map<String,XMLXsiTypeConverter<?>> |
getXsiTypeMap()
When parsing the XML into JSON, specifies that the values with attribute xsi:type
will be converted to target type defined to client in this configuration
Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
xsi:type="integer" as integer, xsi:type="string" as string |
boolean |
isCloseEmptyTag()
Checks if the parser should automatically close empty XML tags.
|
boolean |
isConvertNilAttributeToNull()
When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
should be kept as attribute(
false ), or they should be converted to
null (true ) |
boolean |
shouldTrimWhiteSpace()
Checks if the parser should trim white spaces from XML content.
|
XMLParserConfiguration |
withcDataTagName(String newVal)
The name of the key in a JSON Object that indicates a CDATA section.
|
XMLParserConfiguration |
withCloseEmptyTag(boolean closeEmptyTag)
To enable explicit end tag with empty value.
|
XMLParserConfiguration |
withConvertNilAttributeToNull(boolean newVal)
When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
should be kept as attribute(
false ), or they should be converted to
null (true ) |
XMLParserConfiguration |
withForceList(Set<String> forceList)
When parsing the XML into JSON, specifies that tags that will be converted to arrays
in this configuration
Set<String> to parse the provided tags' values as arrays |
XMLParserConfiguration |
withKeepStrings(boolean newVal)
When parsing the XML into JSON, specifies if values should be kept as strings (
true ), or if
they should try to be guessed into JSON values (numeric, boolean, string) |
XMLParserConfiguration |
withMaxNestingDepth(int maxNestingDepth)
Defines the maximum nesting depth that the parser will descend before throwing an exception
when parsing the XML into JSON.
|
XMLParserConfiguration |
withShouldTrimWhitespace(boolean shouldTrimWhiteSpace)
Sets whether whitespace should be trimmed inside of tags.
|
XMLParserConfiguration |
withXsiTypeMap(Map<String,XMLXsiTypeConverter<?>> xsiTypeMap)
When parsing the XML into JSON, specifies that the values with attribute xsi:type
will be converted to target type defined to client in this configuration
Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
xsi:type="integer" as integer, xsi:type="string" as string |
getMaxNestingDepth, isKeepStrings
public static final XMLParserConfiguration ORIGINAL
public static final XMLParserConfiguration KEEP_STRINGS
public XMLParserConfiguration()
@Deprecated public XMLParserConfiguration(boolean keepStrings)
keepStrings
- true
to parse all values as string.
false
to try and convert XML string values into a JSON value.@Deprecated public XMLParserConfiguration(String cDataTagName)
null
to
disable CDATA processingcDataTagName
- null
to disable CDATA processing. Any other value
to use that value as the JSONObject key name to process as CDATA.@Deprecated public XMLParserConfiguration(boolean keepStrings, String cDataTagName)
keepStrings
- true
to parse all values as string.
false
to try and convert XML string values into a JSON value.cDataTagName
- null
to disable CDATA processing. Any other value
to use that value as the JSONObject key name to process as CDATA.@Deprecated public XMLParserConfiguration(boolean keepStrings, String cDataTagName, boolean convertNilAttributeToNull)
keepStrings
- true
to parse all values as string.
false
to try and convert XML string values into a JSON value.cDataTagName
- null
to disable CDATA processing. Any other value
to use that value as the JSONObject key name to process as CDATA.convertNilAttributeToNull
- true
to parse values with attribute xsi:nil="true" as null.
false
to parse values with attribute xsi:nil="true" as {"xsi:nil":true}.protected XMLParserConfiguration clone()
clone
in class ParserConfiguration
public XMLParserConfiguration withKeepStrings(boolean newVal)
true
), or if
they should try to be guessed into JSON values (numeric, boolean, string)withKeepStrings
in class ParserConfiguration
newVal
- new value to use for the keepStrings
configuration option.public String getcDataTagName()
null
to indicate no CDATA
processing.cDataTagName
configuration value.public XMLParserConfiguration withcDataTagName(String newVal)
null
to indicate no CDATA
processing.newVal
- new value to use for the cDataTagName
configuration option.public boolean isConvertNilAttributeToNull()
false
), or they should be converted to
null
(true
)convertNilAttributeToNull
configuration value.public XMLParserConfiguration withConvertNilAttributeToNull(boolean newVal)
false
), or they should be converted to
null
(true
)newVal
- new value to use for the convertNilAttributeToNull
configuration option.public Map<String,XMLXsiTypeConverter<?>> getXsiTypeMap()
Map<String, XMLXsiTypeConverter<?>>
to parse values with attribute
xsi:type="integer" as integer, xsi:type="string" as stringxsiTypeMap
unmodifiable configuration map.public XMLParserConfiguration withXsiTypeMap(Map<String,XMLXsiTypeConverter<?>> xsiTypeMap)
Map<String, XMLXsiTypeConverter<?>>
to parse values with attribute
xsi:type="integer" as integer, xsi:type="string" as stringxsiTypeMap
- new HashMap<String, XMLXsiTypeConverter<?>>()
to parse values with attribute
xsi:type="integer" as integer, xsi:type="string" as stringpublic Set<String> getForceList()
Set<String>
to parse the provided tags' values as arraysforceList
unmodifiable configuration set.public XMLParserConfiguration withForceList(Set<String> forceList)
Set<String>
to parse the provided tags' values as arraysforceList
- new HashSet<String>()
to parse the provided tags' values as arrayspublic XMLParserConfiguration withMaxNestingDepth(int maxNestingDepth)
withMaxNestingDepth
in class ParserConfiguration
maxNestingDepth
- the maximum nesting depth allowed to the XML parserpublic XMLParserConfiguration withCloseEmptyTag(boolean closeEmptyTag)
closeEmptyTag
- new value for the closeEmptyTag propertypublic XMLParserConfiguration withShouldTrimWhitespace(boolean shouldTrimWhiteSpace)
shouldTrimWhiteSpace
- boolean to set trimming on or off. Off is default.public boolean isCloseEmptyTag()
true
if empty XML tags should be automatically closed, false
otherwise.public boolean shouldTrimWhiteSpace()
true
if white spaces should be trimmed, false
otherwise.Copyright © 2024. All rights reserved.