Skip to content

Commit

Permalink
committing
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Congiu committed Jan 20, 2014
1 parent 13764d5 commit 8aab1ef
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/openx/data/jsonserde/json/CDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(',');
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public JSONException(Throwable cause) {
this.cause = cause;
}

@Override
public Throwable getCause() {
return this.cause;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/openx/data/jsonserde/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/org/openx/data/jsonserde/json/JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand All @@ -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 ||
Expand Down Expand Up @@ -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();
Expand All @@ -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
}


Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Map<String, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 8aab1ef

Please sign in to comment.