- /**
- * Produce a comma delimited text row from a JSONArray. Values containing
- * the comma character will be quoted. Troublesome characters may be
- * removed.
- * @param ja A JSONArray of strings.
- * @return A string ending in NEWLINE.
- */
- public static String rowToString(JSONArray ja) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < ja.length(); i += 1) {
- if (i > 0) {
- sb.append(',');
- }
- Object object = ja.opt(i);
- if (object != null) {
- String string = object.toString();
- if (string.length() > 0 && (string.indexOf(',') >= 0 ||
- string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
- string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
- sb.append('"');
- int length = string.length();
- for (int j = 0; j < length; j += 1) {
- char c = string.charAt(j);
- if (c >= ' ' && c != '"') {
- sb.append(c);
- }
- }
- sb.append('"');
- } else {
- sb.append(string);
- }
+ /**
+ * Produce a comma delimited text row from a JSONArray. Values containing the
+ * comma character will be quoted. Troublesome characters may be removed.
+ *
+ * @param ja
+ * A JSONArray of strings.
+ * @return A string ending in NEWLINE.
+ */
+ public static String rowToString(JSONArray ja)
+ {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < ja.length(); i += 1)
+ {
+ if (i > 0)
+ {
+ sb.append(',');
+ }
+ Object object = ja.opt(i);
+ if (object != null)
+ {
+ String string = object.toString();
+ if (string.length() > 0 && (string.indexOf(',') >= 0
+ || string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0
+ || string.indexOf(0) >= 0 || string.charAt(0) == '"'))
+ {
+ sb.append('"');
+ int length = string.length();
+ for (int j = 0; j < length; j += 1)
+ {
+ char c = string.charAt(j);
+ if (c >= ' ' && c != '"')
+ {
+ sb.append(c);