@@ -39,14 +39,14 @@ public class XMLParserConfiguration {
3939 * they should try to be guessed into JSON values (numeric, boolean, string)
4040 */
4141 private boolean keepStrings ;
42-
42+
4343 /**
4444 * The name of the key in a JSON Object that indicates a CDATA section. Historically this has
4545 * been the value "content" but can be changed. Use <code>null</code> to indicate no CDATA
4646 * processing.
4747 */
4848 private String cDataTagName ;
49-
49+
5050 /**
5151 * When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
5252 * should be kept as attribute(<code>false</code>), or they should be converted to
@@ -66,8 +66,7 @@ public class XMLParserConfiguration {
6666 private Set <String > forceList ;
6767
6868 /**
69- * When parsing the XML into JSON, specifies the tags whose values should be converted
70- * to arrays
69+ * The maximum nesting depth when parsing a XML document to JSON.
7170 */
7271 private int maxNestingDepth = DEFAULT_MAXIMUM_NESTING_DEPTH ;
7372
@@ -157,15 +156,18 @@ public XMLParserConfiguration (final boolean keepStrings, final String cDataTagN
157156 * <code>false</code> to parse values with attribute xsi:nil="true" as {"xsi:nil":true}.
158157 * @param xsiTypeMap <code>new HashMap<String, XMLXsiTypeConverter<?>>()</code> to parse values with attribute
159158 * xsi:type="integer" as integer, xsi:type="string" as string
160- * @param forceList <code>new HashSet<String>()</code> to parse the provided tags' values as arrays
159+ * @param forceList <code>new HashSet<String>()</code> to parse the provided tags' values as arrays
160+ * @param maxNestingDepth <code>int</code> to limit the nesting depth
161161 */
162162 private XMLParserConfiguration (final boolean keepStrings , final String cDataTagName ,
163- final boolean convertNilAttributeToNull , final Map <String , XMLXsiTypeConverter <?>> xsiTypeMap , final Set <String > forceList ) {
163+ final boolean convertNilAttributeToNull , final Map <String , XMLXsiTypeConverter <?>> xsiTypeMap , final Set <String > forceList ,
164+ final int maxNestingDepth ) {
164165 this .keepStrings = keepStrings ;
165166 this .cDataTagName = cDataTagName ;
166167 this .convertNilAttributeToNull = convertNilAttributeToNull ;
167168 this .xsiTypeMap = Collections .unmodifiableMap (xsiTypeMap );
168169 this .forceList = Collections .unmodifiableSet (forceList );
170+ this .maxNestingDepth = maxNestingDepth ;
169171 }
170172
171173 /**
@@ -183,14 +185,15 @@ protected XMLParserConfiguration clone() {
183185 this .cDataTagName ,
184186 this .convertNilAttributeToNull ,
185187 this .xsiTypeMap ,
186- this .forceList
188+ this .forceList ,
189+ this .maxNestingDepth
187190 );
188191 }
189-
192+
190193 /**
191194 * When parsing the XML into JSON, specifies if values should be kept as strings (<code>true</code>), or if
192195 * they should try to be guessed into JSON values (numeric, boolean, string)
193- *
196+ *
194197 * @return The <code>keepStrings</code> configuration value.
195198 */
196199 public boolean isKeepStrings () {
@@ -200,10 +203,10 @@ public boolean isKeepStrings() {
200203 /**
201204 * When parsing the XML into JSON, specifies if values should be kept as strings (<code>true</code>), or if
202205 * they should try to be guessed into JSON values (numeric, boolean, string)
203- *
206+ *
204207 * @param newVal
205208 * new value to use for the <code>keepStrings</code> configuration option.
206- *
209+ *
207210 * @return The existing configuration will not be modified. A new configuration is returned.
208211 */
209212 public XMLParserConfiguration withKeepStrings (final boolean newVal ) {
@@ -216,7 +219,7 @@ public XMLParserConfiguration withKeepStrings(final boolean newVal) {
216219 * The name of the key in a JSON Object that indicates a CDATA section. Historically this has
217220 * been the value "content" but can be changed. Use <code>null</code> to indicate no CDATA
218221 * processing.
219- *
222+ *
220223 * @return The <code>cDataTagName</code> configuration value.
221224 */
222225 public String getcDataTagName () {
@@ -227,10 +230,10 @@ public String getcDataTagName() {
227230 * The name of the key in a JSON Object that indicates a CDATA section. Historically this has
228231 * been the value "content" but can be changed. Use <code>null</code> to indicate no CDATA
229232 * processing.
230- *
233+ *
231234 * @param newVal
232235 * new value to use for the <code>cDataTagName</code> configuration option.
233- *
236+ *
234237 * @return The existing configuration will not be modified. A new configuration is returned.
235238 */
236239 public XMLParserConfiguration withcDataTagName (final String newVal ) {
@@ -243,7 +246,7 @@ public XMLParserConfiguration withcDataTagName(final String newVal) {
243246 * When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
244247 * should be kept as attribute(<code>false</code>), or they should be converted to
245248 * <code>null</code>(<code>true</code>)
246- *
249+ *
247250 * @return The <code>convertNilAttributeToNull</code> configuration value.
248251 */
249252 public boolean isConvertNilAttributeToNull () {
@@ -254,10 +257,10 @@ public boolean isConvertNilAttributeToNull() {
254257 * When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
255258 * should be kept as attribute(<code>false</code>), or they should be converted to
256259 * <code>null</code>(<code>true</code>)
257- *
260+ *
258261 * @param newVal
259262 * new value to use for the <code>convertNilAttributeToNull</code> configuration option.
260- *
263+ *
261264 * @return The existing configuration will not be modified. A new configuration is returned.
262265 */
263266 public XMLParserConfiguration withConvertNilAttributeToNull (final boolean newVal ) {
@@ -295,7 +298,7 @@ public XMLParserConfiguration withXsiTypeMap(final Map<String, XMLXsiTypeConvert
295298
296299 /**
297300 * When parsing the XML into JSON, specifies that tags that will be converted to arrays
298- * in this configuration {@code Set<String>} to parse the provided tags' values as arrays
301+ * in this configuration {@code Set<String>} to parse the provided tags' values as arrays
299302 * @return <code>forceList</code> unmodifiable configuration set.
300303 */
301304 public Set <String > getForceList () {
@@ -304,8 +307,8 @@ public Set<String> getForceList() {
304307
305308 /**
306309 * When parsing the XML into JSON, specifies that tags that will be converted to arrays
307- * in this configuration {@code Set<String>} to parse the provided tags' values as arrays
308- * @param forceList {@code new HashSet<String>()} to parse the provided tags' values as arrays
310+ * in this configuration {@code Set<String>} to parse the provided tags' values as arrays
311+ * @param forceList {@code new HashSet<String>()} to parse the provided tags' values as arrays
309312 * @return The existing configuration will not be modified. A new configuration is returned.
310313 */
311314 public XMLParserConfiguration withForceList (final Set <String > forceList ) {
@@ -327,8 +330,9 @@ public int getMaxNestingDepth() {
327330 /**
328331 * Defines the maximum nesting depth that the parser will descend before throwing an exception
329332 * when parsing the XML into JSON. The default max nesting depth is 512, which means the parser
330- * will go as deep as the maximum call stack size allows. Using any negative value as a
331- * parameter is equivalent to setting no limit to the nesting depth.
333+ * will throw a JsonException if the maximum depth is reached.
334+ * Using any negative value as a parameter is equivalent to setting no limit to the nesting depth,
335+ * which means the parses will go as deep as the maximum call stack size allows.
332336 * @param maxNestingDepth the maximum nesting depth allowed to the XML parser
333337 * @return The existing configuration will not be modified. A new configuration is returned.
334338 */
0 commit comments