mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
fix: amend XMLParserConfiguration.clone() to include the new maxNestingDepth param.
Amend Javadoc for XML and XMLParserConfiguration classes.
This commit is contained in:
parent
401495ae86
commit
2391d248cc
@ -229,8 +229,12 @@ public class XML {
|
|||||||
* The JSONObject that will include the new material.
|
* The JSONObject that will include the new material.
|
||||||
* @param name
|
* @param name
|
||||||
* The tag name.
|
* The tag name.
|
||||||
|
* @param config
|
||||||
|
* The XML parser configuration.
|
||||||
|
* @param currentNestingDepth
|
||||||
|
* The current nesting depth.
|
||||||
* @return true if the close tag is processed.
|
* @return true if the close tag is processed.
|
||||||
* @throws JSONException
|
* @throws JSONException Thrown if any parsing error occurs.
|
||||||
*/
|
*/
|
||||||
private static boolean parse(XMLTokener x, JSONObject context, String name, XMLParserConfiguration config, int currentNestingDepth)
|
private static boolean parse(XMLTokener x, JSONObject context, String name, XMLParserConfiguration config, int currentNestingDepth)
|
||||||
throws JSONException {
|
throws JSONException {
|
||||||
|
@ -66,8 +66,7 @@ public class XMLParserConfiguration {
|
|||||||
private Set<String> forceList;
|
private Set<String> forceList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When parsing the XML into JSON, specifies the tags whose values should be converted
|
* The maximum nesting depth when parsing a XML document to JSON.
|
||||||
* to arrays
|
|
||||||
*/
|
*/
|
||||||
private int maxNestingDepth = DEFAULT_MAXIMUM_NESTING_DEPTH;
|
private int maxNestingDepth = DEFAULT_MAXIMUM_NESTING_DEPTH;
|
||||||
|
|
||||||
@ -158,14 +157,17 @@ public class XMLParserConfiguration {
|
|||||||
* @param xsiTypeMap <code>new HashMap<String, XMLXsiTypeConverter<?>>()</code> to parse values with attribute
|
* @param xsiTypeMap <code>new HashMap<String, XMLXsiTypeConverter<?>>()</code> to parse values with attribute
|
||||||
* xsi:type="integer" as integer, xsi:type="string" as string
|
* xsi:type="integer" as integer, xsi:type="string" as string
|
||||||
* @param forceList <code>new HashSet<String>()</code> to parse the provided tags' values as arrays
|
* @param forceList <code>new HashSet<String>()</code> to parse the provided tags' values as arrays
|
||||||
|
* @param maxNestingDepth <code>int</code> to limit the nesting depth
|
||||||
*/
|
*/
|
||||||
private XMLParserConfiguration (final boolean keepStrings, final String cDataTagName,
|
private XMLParserConfiguration (final boolean keepStrings, final String cDataTagName,
|
||||||
final boolean convertNilAttributeToNull, final Map<String, XMLXsiTypeConverter<?>> xsiTypeMap, final Set<String> forceList ) {
|
final boolean convertNilAttributeToNull, final Map<String, XMLXsiTypeConverter<?>> xsiTypeMap, final Set<String> forceList,
|
||||||
|
final int maxNestingDepth) {
|
||||||
this.keepStrings = keepStrings;
|
this.keepStrings = keepStrings;
|
||||||
this.cDataTagName = cDataTagName;
|
this.cDataTagName = cDataTagName;
|
||||||
this.convertNilAttributeToNull = convertNilAttributeToNull;
|
this.convertNilAttributeToNull = convertNilAttributeToNull;
|
||||||
this.xsiTypeMap = Collections.unmodifiableMap(xsiTypeMap);
|
this.xsiTypeMap = Collections.unmodifiableMap(xsiTypeMap);
|
||||||
this.forceList = Collections.unmodifiableSet(forceList);
|
this.forceList = Collections.unmodifiableSet(forceList);
|
||||||
|
this.maxNestingDepth = maxNestingDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +185,8 @@ public class XMLParserConfiguration {
|
|||||||
this.cDataTagName,
|
this.cDataTagName,
|
||||||
this.convertNilAttributeToNull,
|
this.convertNilAttributeToNull,
|
||||||
this.xsiTypeMap,
|
this.xsiTypeMap,
|
||||||
this.forceList
|
this.forceList,
|
||||||
|
this.maxNestingDepth
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,8 +330,9 @@ public class XMLParserConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Defines the maximum nesting depth that the parser will descend before throwing an exception
|
* Defines the maximum nesting depth that the parser will descend before throwing an exception
|
||||||
* when parsing the XML into JSON. The default max nesting depth is 512, which means the parser
|
* when parsing the XML into JSON. The default max nesting depth is 512, which means the parser
|
||||||
* will go as deep as the maximum call stack size allows. Using any negative value as a
|
* will throw a JsonException if the maximum depth is reached.
|
||||||
* parameter is equivalent to setting no limit to the nesting depth.
|
* Using any negative value as a parameter is equivalent to setting no limit to the nesting depth,
|
||||||
|
* which means the parses will go as deep as the maximum call stack size allows.
|
||||||
* @param maxNestingDepth the maximum nesting depth allowed to the XML parser
|
* @param maxNestingDepth the maximum nesting depth allowed to the XML parser
|
||||||
* @return The existing configuration will not be modified. A new configuration is returned.
|
* @return The existing configuration will not be modified. A new configuration is returned.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user