Skip to content

Commit fd0d115

Browse files
Merge pull request stleary#41 from ajayk/master
Code formatting Tabs to spaces and Minor java cleanup
2 parents 6394d92 + 9420bb7 commit fd0d115

9 files changed

+436
-436
lines changed

CDL.java

+45-45
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ private static String getValue(JSONTokener x) throws JSONException {
6464
return null;
6565
case '"':
6666
case '\'':
67-
q = c;
68-
sb = new StringBuffer();
69-
for (;;) {
70-
c = x.next();
71-
if (c == q) {
72-
break;
73-
}
67+
q = c;
68+
sb = new StringBuffer();
69+
for (;;) {
70+
c = x.next();
71+
if (c == q) {
72+
break;
73+
}
7474
if (c == 0 || c == '\n' || c == '\r') {
7575
throw x.syntaxError("Missing close quote '" + q + "'.");
7676
}
7777
sb.append(c);
78-
}
78+
}
7979
return sb.toString();
8080
case ',':
8181
x.back();
@@ -98,7 +98,7 @@ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
9898
String value = getValue(x);
9999
char c = x.next();
100100
if (value == null ||
101-
(ja.length() == 0 && value.length() == 0 && c != ',')) {
101+
(ja.length() == 0 && value.length() == 0 && c != ',')) {
102102
return null;
103103
}
104104
ja.put(value);
@@ -135,43 +135,43 @@ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
135135
}
136136

137137
/**
138-
* Produce a comma delimited text row from a JSONArray. Values containing
139-
* the comma character will be quoted. Troublesome characters may be
140-
* removed.
141-
* @param ja A JSONArray of strings.
142-
* @return A string ending in NEWLINE.
143-
*/
144-
public static String rowToString(JSONArray ja) {
145-
StringBuffer sb = new StringBuffer();
146-
for (int i = 0; i < ja.length(); i += 1) {
147-
if (i > 0) {
148-
sb.append(',');
149-
}
150-
Object object = ja.opt(i);
151-
if (object != null) {
152-
String string = object.toString();
153-
if (string.length() > 0 && (string.indexOf(',') >= 0 ||
154-
string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
155-
string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
156-
sb.append('"');
157-
int length = string.length();
158-
for (int j = 0; j < length; j += 1) {
159-
char c = string.charAt(j);
160-
if (c >= ' ' && c != '"') {
161-
sb.append(c);
162-
}
163-
}
164-
sb.append('"');
165-
} else {
166-
sb.append(string);
167-
}
168-
}
169-
}
170-
sb.append('\n');
171-
return sb.toString();
172-
}
138+
* Produce a comma delimited text row from a JSONArray. Values containing
139+
* the comma character will be quoted. Troublesome characters may be
140+
* removed.
141+
* @param ja A JSONArray of strings.
142+
* @return A string ending in NEWLINE.
143+
*/
144+
public static String rowToString(JSONArray ja) {
145+
StringBuffer sb = new StringBuffer();
146+
for (int i = 0; i < ja.length(); i += 1) {
147+
if (i > 0) {
148+
sb.append(',');
149+
}
150+
Object object = ja.opt(i);
151+
if (object != null) {
152+
String string = object.toString();
153+
if (string.length() > 0 && (string.indexOf(',') >= 0 ||
154+
string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
155+
string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
156+
sb.append('"');
157+
int length = string.length();
158+
for (int j = 0; j < length; j += 1) {
159+
char c = string.charAt(j);
160+
if (c >= ' ' && c != '"') {
161+
sb.append(c);
162+
}
163+
}
164+
sb.append('"');
165+
} else {
166+
sb.append(string);
167+
}
168+
}
169+
}
170+
sb.append('\n');
171+
return sb.toString();
172+
}
173173

174-
/**
174+
/**
175175
* Produce a JSONArray of JSONObjects from a comma delimited text string,
176176
* using the first row as a source of names.
177177
* @param string The comma delimited text.

HTTP.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ public static String toString(JSONObject jo) throws JSONException {
148148
sb.append(CRLF);
149149
while (keys.hasNext()) {
150150
string = keys.next().toString();
151-
if (!string.equals("HTTP-Version") && !string.equals("Status-Code") &&
152-
!string.equals("Reason-Phrase") && !string.equals("Method") &&
153-
!string.equals("Request-URI") && !jo.isNull(string)) {
151+
if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) &&
152+
!"Reason-Phrase".equals(string) && !"Method".equals(string) &&
153+
!"Request-URI".equals(string) && !jo.isNull(string)) {
154154
sb.append(string);
155155
sb.append(": ");
156156
sb.append(jo.getString(string));

JSONException.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* @version 2010-12-24
77
*/
88
public class JSONException extends Exception {
9-
private static final long serialVersionUID = 0;
10-
private Throwable cause;
9+
private static final long serialVersionUID = 0;
10+
private Throwable cause;
1111

1212
/**
1313
* Constructs a JSONException with an explanatory message.

0 commit comments

Comments
 (0)