Package com.util.org.json
Class XMLParserConfiguration
- java.lang.Object
-
- com.util.org.json.XMLParserConfiguration
-
public class XMLParserConfiguration extends java.lang.ObjectConfiguration object for the XML parser. The configuration is immutable.- Author:
- AylwardJ
-
-
Field Summary
Fields Modifier and Type Field Description static XMLParserConfigurationKEEP_STRINGSOriginal configuration of the XML Parser except that values are kept as strings.static XMLParserConfigurationORIGINALOriginal Configuration of the XML Parser.
-
Constructor Summary
Constructors Constructor 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.XMLParserConfiguration(boolean keepStrings, java.lang.String cDataTagName)Deprecated.This constructor has been deprecated in favor of using the new builder pattern for the configuration.XMLParserConfiguration(boolean keepStrings, java.lang.String cDataTagName, boolean convertNilAttributeToNull)Deprecated.This constructor has been deprecated in favor of using the new builder pattern for the configuration.XMLParserConfiguration(java.lang.String cDataTagName)Deprecated.This constructor has been deprecated in favor of using the new builder pattern for the configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetcDataTagName()The name of the key in a JSON Object that indicates a CDATA section.java.util.Set<java.lang.String>getForceList()When parsing the XML into JSON, specifies that tags that will be converted to arrays in this configurationSet<String>to parse the provided tags' values as arraysjava.util.Map<java.lang.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 configurationMap<String, XMLXsiTypeConverter<?>>to parse values with attribute xsi:type="integer" as integer, xsi:type="string" as stringbooleanisConvertNilAttributeToNull()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 tonull(true)booleanisKeepStrings()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)XMLParserConfigurationwithcDataTagName(java.lang.String newVal)The name of the key in a JSON Object that indicates a CDATA section.XMLParserConfigurationwithConvertNilAttributeToNull(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 tonull(true)XMLParserConfigurationwithForceList(java.util.Set<java.lang.String> forceList)When parsing the XML into JSON, specifies that tags that will be converted to arrays in this configurationSet<String>to parse the provided tags' values as arraysXMLParserConfigurationwithKeepStrings(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)XMLParserConfigurationwithXsiTypeMap(java.util.Map<java.lang.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 configurationMap<String, XMLXsiTypeConverter<?>>to parse values with attribute xsi:type="integer" as integer, xsi:type="string" as string
-
-
-
Field Detail
-
ORIGINAL
public static final XMLParserConfiguration ORIGINAL
Original Configuration of the XML Parser.
-
KEEP_STRINGS
public static final XMLParserConfiguration KEEP_STRINGS
Original configuration of the XML Parser except that values are kept as strings.
-
-
Constructor Detail
-
XMLParserConfiguration
public XMLParserConfiguration()
Default parser configuration. Does not keep strings (tries to implicitly convert values), and the CDATA Tag Name is "content".
-
XMLParserConfiguration
@Deprecated public 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.Configure the parser string processing and use the default CDATA Tag Name as "content".- Parameters:
keepStrings-trueto parse all values as string.falseto try and convert XML string values into a JSON value.
-
XMLParserConfiguration
@Deprecated public XMLParserConfiguration(java.lang.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.Configure the parser string processing to try and convert XML values to JSON values and use the passed CDATA Tag Name the processing value. Passnullto disable CDATA processing- Parameters:
cDataTagName-nullto disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.
-
XMLParserConfiguration
@Deprecated public XMLParserConfiguration(boolean keepStrings, java.lang.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.Configure the parser to use custom settings.- Parameters:
keepStrings-trueto parse all values as string.falseto try and convert XML string values into a JSON value.cDataTagName-nullto disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.
-
XMLParserConfiguration
@Deprecated public XMLParserConfiguration(boolean keepStrings, java.lang.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.Configure the parser to use custom settings.- Parameters:
keepStrings-trueto parse all values as string.falseto try and convert XML string values into a JSON value.cDataTagName-nullto disable CDATA processing. Any other value to use that value as the JSONObject key name to process as CDATA.convertNilAttributeToNull-trueto parse values with attribute xsi:nil="true" as null.falseto parse values with attribute xsi:nil="true" as {"xsi:nil":true}.
-
-
Method Detail
-
isKeepStrings
public boolean isKeepStrings()
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)- Returns:
- The
keepStringsconfiguration value.
-
withKeepStrings
public 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)- Parameters:
newVal- new value to use for thekeepStringsconfiguration option.- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
getcDataTagName
public java.lang.String getcDataTagName()
The name of the key in a JSON Object that indicates a CDATA section. Historically this has been the value "content" but can be changed. Usenullto indicate no CDATA processing.- Returns:
- The
cDataTagNameconfiguration value.
-
withcDataTagName
public XMLParserConfiguration withcDataTagName(java.lang.String newVal)
The name of the key in a JSON Object that indicates a CDATA section. Historically this has been the value "content" but can be changed. Usenullto indicate no CDATA processing.- Parameters:
newVal- new value to use for thecDataTagNameconfiguration option.- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
isConvertNilAttributeToNull
public 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 tonull(true)- Returns:
- The
convertNilAttributeToNullconfiguration value.
-
withConvertNilAttributeToNull
public 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 tonull(true)- Parameters:
newVal- new value to use for theconvertNilAttributeToNullconfiguration option.- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
getXsiTypeMap
public java.util.Map<java.lang.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 configurationMap<String, XMLXsiTypeConverter<?>>to parse values with attribute xsi:type="integer" as integer, xsi:type="string" as string- Returns:
xsiTypeMapunmodifiable configuration map.
-
withXsiTypeMap
public XMLParserConfiguration withXsiTypeMap(java.util.Map<java.lang.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 configurationMap<String, XMLXsiTypeConverter<?>>to parse values with attribute xsi:type="integer" as integer, xsi:type="string" as string- Parameters:
xsiTypeMap-new HashMap<String, XMLXsiTypeConverter<?>>()to parse values with attribute xsi:type="integer" as integer, xsi:type="string" as string- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
getForceList
public java.util.Set<java.lang.String> getForceList()
When parsing the XML into JSON, specifies that tags that will be converted to arrays in this configurationSet<String>to parse the provided tags' values as arrays- Returns:
forceListunmodifiable configuration set.
-
withForceList
public XMLParserConfiguration withForceList(java.util.Set<java.lang.String> forceList)
When parsing the XML into JSON, specifies that tags that will be converted to arrays in this configurationSet<String>to parse the provided tags' values as arrays- Parameters:
forceList-new HashSet<String>()to parse the provided tags' values as arrays- Returns:
- The existing configuration will not be modified. A new configuration is returned.
-
-