diff --git a/src/main/java/org/openx/data/jsonserde/json/CDL.java b/src/main/java/org/openx/data/jsonserde/json/CDL.java index d99df448..e310e291 100644 --- a/src/main/java/org/openx/data/jsonserde/json/CDL.java +++ b/src/main/java/org/openx/data/jsonserde/json/CDL.java @@ -142,7 +142,7 @@ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) * @return A string ending in NEWLINE. */ public static String rowToString(JSONArray ja) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < ja.length(); i += 1) { if (i > 0) { sb.append(','); @@ -267,7 +267,7 @@ public static String toString(JSONArray names, JSONArray ja) if (names == null || names.length() == 0) { return null; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < ja.length(); i += 1) { JSONObject jo = ja.optJSONObject(i); if (jo != null) { diff --git a/src/main/java/org/openx/data/jsonserde/json/JSONException.java b/src/main/java/org/openx/data/jsonserde/json/JSONException.java index 956e4b97..60a82562 100644 --- a/src/main/java/org/openx/data/jsonserde/json/JSONException.java +++ b/src/main/java/org/openx/data/jsonserde/json/JSONException.java @@ -22,6 +22,7 @@ public JSONException(Throwable cause) { this.cause = cause; } + @Override public Throwable getCause() { return this.cause; } diff --git a/src/main/java/org/openx/data/jsonserde/json/JSONObject.java b/src/main/java/org/openx/data/jsonserde/json/JSONObject.java index d07f1a69..b410e18f 100644 --- a/src/main/java/org/openx/data/jsonserde/json/JSONObject.java +++ b/src/main/java/org/openx/data/jsonserde/json/JSONObject.java @@ -167,8 +167,6 @@ public JSONObject() { * Missing keys are ignored. * @param jo A JSONObject. * @param names An array of strings. - * @throws JSONException - * @exception JSONException If a value is a non-finite number or if a name is duplicated. */ public JSONObject(JSONObject jo, String[] names) { this(); diff --git a/src/main/java/org/openx/data/jsonserde/json/JSONTokener.java b/src/main/java/org/openx/data/jsonserde/json/JSONTokener.java index 6bad8697..a10ca9d1 100644 --- a/src/main/java/org/openx/data/jsonserde/json/JSONTokener.java +++ b/src/main/java/org/openx/data/jsonserde/json/JSONTokener.java @@ -68,6 +68,8 @@ public JSONTokener(Reader reader) { /** * Construct a JSONTokener from an InputStream. + * @param inputStream + * @throws org.openx.data.jsonserde.json.JSONException */ public JSONTokener(InputStream inputStream) throws JSONException { this(new InputStreamReader(inputStream)); @@ -88,6 +90,7 @@ public JSONTokener(String s) { * Back up one character. This provides a sort of lookahead capability, * so that you can test for a digit or letter before attempting to parse * the next number or identifier. + * @throws org.openx.data.jsonserde.json.JSONException */ public void back() throws JSONException { if (usePrevious || index <= 0) { @@ -128,6 +131,7 @@ public boolean end() { * Determine if the source string still contains characters that next() * can consume. * @return true if not yet at the end of the source. + * @throws org.openx.data.jsonserde.json.JSONException */ public boolean more() throws JSONException { next(); @@ -143,6 +147,7 @@ public boolean more() throws JSONException { * Get the next character in the source string. * * @return The next character, or 0 if past the end of the source string. + * @throws org.openx.data.jsonserde.json.JSONException */ public char next() throws JSONException { int c; @@ -249,7 +254,7 @@ public char nextClean() throws JSONException { */ public String nextString(char quote) throws JSONException { char c; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (;;) { c = next(); switch (c) { @@ -303,9 +308,10 @@ public String nextString(char quote) throws JSONException { * end of line, whichever comes first. * @param delimiter A delimiter character. * @return A string. + * @throws org.openx.data.jsonserde.json.JSONException */ public String nextTo(char delimiter) throws JSONException { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (;;) { char c = next(); if (c == delimiter || c == 0 || c == '\n' || c == '\r') { @@ -324,10 +330,11 @@ public String nextTo(char delimiter) throws JSONException { * characters or the end of line, whichever comes first. * @param delimiters A set of delimiter characters. * @return A string, trimmed. + * @throws org.openx.data.jsonserde.json.JSONException */ public String nextTo(String delimiters) throws JSONException { char c; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (;;) { c = next(); if (delimiters.indexOf(c) >= 0 || c == 0 || @@ -365,16 +372,8 @@ public Object nextValue() throws JSONException { return new JSONArray(this); } - /* - * Handle unquoted text. This could be the values true, false, or - * null, or it can be a number. An implementation (such as this one) - * is allowed to also accept non-standard forms. - * - * Accumulate characters until we reach the end of the text or a - * formatting character. - */ - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { sb.append(c); c = next(); @@ -385,7 +384,8 @@ public Object nextValue() throws JSONException { if (string.equals("")) { throw syntaxError("Missing value"); } - return JSONObject.stringToValue(string); + //return JSONObject.stringToValue(string); + return string; // we let the SerDe get the right type if numeric } @@ -395,6 +395,7 @@ public Object nextValue() throws JSONException { * @param to A character to skip to. * @return The requested character, or zero if the requested character * is not found. + * @throws org.openx.data.jsonserde.json.JSONException */ public char skipTo(char to) throws JSONException { char c; diff --git a/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructOIOptions.java b/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructOIOptions.java index 67b440c1..c42b78d7 100644 --- a/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructOIOptions.java +++ b/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructOIOptions.java @@ -37,7 +37,7 @@ public Map getMappings() { @Override public boolean equals(Object obj) { - if(!(obj instanceof JsonStructOIOptions) || obj == null) { + if(obj == null || !(obj instanceof JsonStructOIOptions) ) { return false ; } else { JsonStructOIOptions oio = (JsonStructOIOptions) obj; diff --git a/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructObjectInspector.java b/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructObjectInspector.java index 5db3a364..ed83e1ac 100644 --- a/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructObjectInspector.java +++ b/src/main/java/org/openx/data/jsonserde/objectinspector/JsonStructObjectInspector.java @@ -53,7 +53,6 @@ public Object getStructFieldData(Object data, StructField fieldRef) { if (data == null) { return null; } - JSONObject obj = null ; if( data instanceof JSONObject) { return getStructFieldDataFromJsonObject((JSONObject) data, fieldRef );