diff --git a/src/main/java/org/json/JSONML.java b/src/main/java/org/json/JSONML.java index a58137e..4aea014 100644 --- a/src/main/java/org/json/JSONML.java +++ b/src/main/java/org/json/JSONML.java @@ -31,7 +31,7 @@ public class JSONML { int currentNestingDepth ) throws JSONException { return parse(x,arrayForm, ja, - keepStrings ? XMLtoJSONMLParserConfiguration.KEEP_STRINGS : XMLtoJSONMLParserConfiguration.ORIGINAL, + keepStrings ? JSONMLParserConfiguration.KEEP_STRINGS : JSONMLParserConfiguration.ORIGINAL, currentNestingDepth); } @@ -41,9 +41,9 @@ public class JSONML { * @param arrayForm true if array form, false if object form. * @param ja The JSONArray that is containing the current tag or null * if we are at the outermost level. - * @param config The XML parser configuration: - * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour; - * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means Don't type-convert text nodes and attribute values. + * @param config The parser configuration: + * JSONMLParserConfiguration.ORIGINAL is the default behaviour; + * JSONMLParserConfiguration.KEEP_STRINGS means Don't type-convert text nodes and attribute values. * @return A JSONArray if the value is the outermost tag, otherwise null. * @throws JSONException if a parsing error occurs */ @@ -51,7 +51,7 @@ public class JSONML { XMLTokener x, boolean arrayForm, JSONArray ja, - XMLtoJSONMLParserConfiguration config, + JSONMLParserConfiguration config, int currentNestingDepth ) throws JSONException { String attribute; @@ -254,7 +254,7 @@ public class JSONML { * @throws JSONException Thrown on error converting to a JSONArray */ public static JSONArray toJSONArray(String string) throws JSONException { - return (JSONArray)parse(new XMLTokener(string), true, null, XMLtoJSONMLParserConfiguration.ORIGINAL, 0); + return (JSONArray)parse(new XMLTokener(string), true, null, JSONMLParserConfiguration.ORIGINAL, 0); } @@ -293,14 +293,14 @@ public class JSONML { * but just leaves it as a string. * Comments, prologs, DTDs, and
{@code <[ [ ]]>} are ignored.
* @param string The source string.
- * @param config The XML parser configuration:
- * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
- * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
+ * @param config The parser configuration:
+ * JSONMLParserConfiguration.ORIGINAL is the default behaviour;
+ * JSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
* or numeric values and will instead be left as strings
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONArray
*/
- public static JSONArray toJSONArray(String string, XMLtoJSONMLParserConfiguration config) throws JSONException {
+ public static JSONArray toJSONArray(String string, JSONMLParserConfiguration config) throws JSONException {
return (JSONArray)parse(new XMLTokener(string), true, null, config, 0);
}
@@ -317,14 +317,14 @@ public class JSONML {
* but just leaves it as a string.
* Comments, prologs, DTDs, and {@code <[ [ ]]>} are ignored.
* @param x An XMLTokener.
- * @param config The XML parser configuration:
- * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
- * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
+ * @param config The parser configuration:
+ * JSONMLParserConfiguration.ORIGINAL is the default behaviour;
+ * JSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
* or numeric values and will instead be left as strings
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONArray
*/
- public static JSONArray toJSONArray(XMLTokener x, XMLtoJSONMLParserConfiguration config) throws JSONException {
+ public static JSONArray toJSONArray(XMLTokener x, JSONMLParserConfiguration config) throws JSONException {
return (JSONArray)parse(x, true, null, config, 0);
}
@@ -416,14 +416,14 @@ public class JSONML {
* Comments, prologs, DTDs, and {@code <[ [ ]]>} are ignored.
* @param string The XML source text.
- * @param config The XML parser configuration:
- * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
- * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
+ * @param config The parser configuration:
+ * JSONMLParserConfiguration.ORIGINAL is the default behaviour;
+ * JSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
* or numeric values and will instead be left as strings
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONObject
*/
- public static JSONObject toJSONObject(String string, XMLtoJSONMLParserConfiguration config) throws JSONException {
+ public static JSONObject toJSONObject(String string, JSONMLParserConfiguration config) throws JSONException {
return (JSONObject)parse(new XMLTokener(string), false, null, config, 0);
}
@@ -476,14 +476,14 @@ public class JSONML {
* Comments, prologs, DTDs, and {@code <[ [ ]]>} are ignored.
* @param x An XMLTokener of the XML source text.
- * @param config The XML parser configuration:
- * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
- * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
+ * @param config The parser configuration:
+ * JSONMLParserConfiguration.ORIGINAL is the default behaviour;
+ * JSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
* or numeric values and will instead be left as strings
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException Thrown on error converting to a JSONObject
*/
- public static JSONObject toJSONObject(XMLTokener x, XMLtoJSONMLParserConfiguration config) throws JSONException {
+ public static JSONObject toJSONObject(XMLTokener x, JSONMLParserConfiguration config) throws JSONException {
return (JSONObject)parse(x, false, null, config, 0);
}
diff --git a/src/main/java/org/json/XMLtoJSONMLParserConfiguration.java b/src/main/java/org/json/JSONMLParserConfiguration.java
similarity index 83%
rename from src/main/java/org/json/XMLtoJSONMLParserConfiguration.java
rename to src/main/java/org/json/JSONMLParserConfiguration.java
index 452f992..26f7386 100644
--- a/src/main/java/org/json/XMLtoJSONMLParserConfiguration.java
+++ b/src/main/java/org/json/JSONMLParserConfiguration.java
@@ -7,7 +7,7 @@ Public Domain.
* Configuration object for the XML to JSONML parser. The configuration is immutable.
*/
@SuppressWarnings({""})
-public class XMLtoJSONMLParserConfiguration {
+public class JSONMLParserConfiguration {
/**
* Used to indicate there's no defined limit to the maximum nesting depth when parsing a XML
* document to JSONML.
@@ -20,11 +20,11 @@ public class XMLtoJSONMLParserConfiguration {
public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = 512;
/** Original Configuration of the XML to JSONML Parser. */
- public static final XMLtoJSONMLParserConfiguration ORIGINAL
- = new XMLtoJSONMLParserConfiguration();
+ public static final JSONMLParserConfiguration ORIGINAL
+ = new JSONMLParserConfiguration();
/** Original configuration of the XML to JSONML Parser except that values are kept as strings. */
- public static final XMLtoJSONMLParserConfiguration KEEP_STRINGS
- = new XMLtoJSONMLParserConfiguration().withKeepStrings(true);
+ public static final JSONMLParserConfiguration KEEP_STRINGS
+ = new JSONMLParserConfiguration().withKeepStrings(true);
/**
* When parsing the XML into JSONML, specifies if values should be kept as strings (true), or if
@@ -40,7 +40,7 @@ public class XMLtoJSONMLParserConfiguration {
/**
* Default parser configuration. Does not keep strings (tries to implicitly convert values).
*/
- public XMLtoJSONMLParserConfiguration() {
+ public JSONMLParserConfiguration() {
this.keepStrings = false;
}
@@ -50,7 +50,7 @@ public class XMLtoJSONMLParserConfiguration {
* false to try and convert XML string values into a JSON value.
* @param maxNestingDepth int to limit the nesting depth
*/
- public XMLtoJSONMLParserConfiguration(final boolean keepStrings, final int maxNestingDepth) {
+ public JSONMLParserConfiguration(final boolean keepStrings, final int maxNestingDepth) {
this.keepStrings = keepStrings;
this.maxNestingDepth = maxNestingDepth;
}
@@ -59,13 +59,13 @@ public class XMLtoJSONMLParserConfiguration {
* Provides a new instance of the same configuration.
*/
@Override
- protected XMLtoJSONMLParserConfiguration clone() {
+ protected JSONMLParserConfiguration clone() {
// future modifications to this method should always ensure a "deep"
// clone in the case of collections. i.e. if a Map is added as a configuration
// item, a new map instance should be created and if possible each value in the
// map should be cloned as well. If the values of the map are known to also
// be immutable, then a shallow clone of the map is acceptable.
- return new XMLtoJSONMLParserConfiguration(
+ return new JSONMLParserConfiguration(
this.keepStrings,
this.maxNestingDepth
);
@@ -90,8 +90,8 @@ public class XMLtoJSONMLParserConfiguration {
*
* @return The existing configuration will not be modified. A new configuration is returned.
*/
- public XMLtoJSONMLParserConfiguration withKeepStrings(final boolean newVal) {
- XMLtoJSONMLParserConfiguration newConfig = this.clone();
+ public JSONMLParserConfiguration withKeepStrings(final boolean newVal) {
+ JSONMLParserConfiguration newConfig = this.clone();
newConfig.keepStrings = newVal;
return newConfig;
}
@@ -114,8 +114,8 @@ public class XMLtoJSONMLParserConfiguration {
* @param maxNestingDepth the maximum nesting depth allowed to the XML parser
* @return The existing configuration will not be modified. A new configuration is returned.
*/
- public XMLtoJSONMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) {
- XMLtoJSONMLParserConfiguration newConfig = this.clone();
+ public JSONMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) {
+ JSONMLParserConfiguration newConfig = this.clone();
if (maxNestingDepth > UNDEFINED_MAXIMUM_NESTING_DEPTH) {
newConfig.maxNestingDepth = maxNestingDepth;
diff --git a/src/test/java/org/json/junit/JSONMLTest.java b/src/test/java/org/json/junit/JSONMLTest.java
index 7d0a285..1514ddd 100644
--- a/src/test/java/org/json/junit/JSONMLTest.java
+++ b/src/test/java/org/json/junit/JSONMLTest.java
@@ -841,7 +841,7 @@ public class JSONMLTest {
final int maxNestingDepth = 42;
try {
- JSONML.toJSONArray(wayTooLongMalformedXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONArray(wayTooLongMalformedXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
fail("Expecting a JSONException");
} catch (JSONException e) {
@@ -864,7 +864,7 @@ public class JSONMLTest {
final int maxNestingDepth = 1;
try {
- JSONML.toJSONArray(perfectlyFineXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONArray(perfectlyFineXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
fail("Expecting a JSONException");
} catch (JSONException e) {
@@ -886,11 +886,11 @@ public class JSONMLTest {
final int maxNestingDepth = 3;
try {
- JSONML.toJSONArray(perfectlyFineXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONArray(perfectlyFineXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
} catch (JSONException e) {
e.printStackTrace();
fail("XML document should be parsed as its maximum depth fits the maxNestingDepth " +
- "parameter of the XMLtoJSONMLParserConfiguration used");
+ "parameter of the JSONMLParserConfiguration used");
}
}
@@ -905,7 +905,7 @@ public class JSONMLTest {
final int maxNestingDepth = 42;
try {
- JSONML.toJSONObject(wayTooLongMalformedXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONObject(wayTooLongMalformedXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
fail("Expecting a JSONException");
} catch (JSONException e) {
@@ -927,7 +927,7 @@ public class JSONMLTest {
final int maxNestingDepth = 1;
try {
- JSONML.toJSONObject(perfectlyFineXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONObject(perfectlyFineXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
fail("Expecting a JSONException");
} catch (JSONException e) {
@@ -949,11 +949,11 @@ public class JSONMLTest {
final int maxNestingDepth = 3;
try {
- JSONML.toJSONObject(perfectlyFineXML, XMLtoJSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
+ JSONML.toJSONObject(perfectlyFineXML, JSONMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
} catch (JSONException e) {
e.printStackTrace();
fail("XML document should be parsed as its maximum depth fits the maxNestingDepth " +
- "parameter of the XMLtoJSONMLParserConfiguration used");
+ "parameter of the JSONMLParserConfiguration used");
}
}