cleanup-after-commit reverted pom.xml version 8 change and tabs in cdl. Updated JavaDocs in cdl

This commit is contained in:
Sean Leary 2024-02-13 20:08:54 -06:00
parent 6358b7f681
commit f164b8c597
2 changed files with 92 additions and 53 deletions

View File

@ -126,9 +126,6 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version> <version>3.5.0</version>
<configuration>
<source>8</source>
</configuration>
<executions> <executions>
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>

View File

@ -40,37 +40,37 @@ public class CDL {
do { do {
c = x.next(); c = x.next();
} while (c == ' ' || c == '\t'); } while (c == ' ' || c == '\t');
if (c == 0) { if (c == 0) {
return null; return null;
} else if (c == '"' || c == '\'') { } else if (c == '"' || c == '\'') {
q = c; q = c;
sb = new StringBuilder(); sb = new StringBuilder();
for (;;) { for (;;) {
c = x.next(); c = x.next();
if (c == q) { if (c == q) {
//Handle escaped double-quote //Handle escaped double-quote
char nextC = x.next(); char nextC = x.next();
if (nextC != '\"') { if (nextC != '\"') {
// if our quote was the end of the file, don't step // if our quote was the end of the file, don't step
if (nextC > 0) { if (nextC > 0) {
x.back(); x.back();
} }
break; break;
} }
} }
if (c == 0 || c == '\n' || c == '\r') { if (c == 0 || c == '\n' || c == '\r') {
throw x.syntaxError("Missing close quote '" + q + "'."); throw x.syntaxError("Missing close quote '" + q + "'.");
} }
sb.append(c); sb.append(c);
} }
return sb.toString(); return sb.toString();
} else if (c == delimiter) { } else if (c == delimiter) {
x.back(); x.back();
return ""; return "";
} }
x.back(); x.back();
return x.nextTo(delimiter); return x.nextTo(delimiter);
} }
/** /**
* Produce a JSONArray of strings from a row of comma delimited values. * Produce a JSONArray of strings from a row of comma delimited values.
@ -83,8 +83,11 @@ public class CDL {
} }
/** /**
* Same as {@link #rowToJSONArray(JSONTokener)}, but with a custom delimiter. * Produce a JSONArray of strings from a row of comma delimited values.
* @see #rowToJSONArray(JSONTokener) * @param x A JSONTokener of the source text.
* @param delimiter custom delimiter char
* @return A JSONArray of strings.
* @throws JSONException if a called function fails
*/ */
public static JSONArray rowToJSONArray(JSONTokener x, char delimiter) throws JSONException { public static JSONArray rowToJSONArray(JSONTokener x, char delimiter) throws JSONException {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
@ -127,9 +130,15 @@ public class CDL {
} }
/** /**
* Same as {@link #rowToJSONObject(JSONArray, JSONTokener)}, but with a custom {@code delimiter}. * Produce a JSONObject from a row of comma delimited text, using a
* * parallel JSONArray of strings to provides the names of the elements.
* @see #rowToJSONObject(JSONArray, JSONTokener) * @param names A JSONArray of names. This is commonly obtained from the
* first row of a comma delimited text file using the rowToJSONArray
* method.
* @param x A JSONTokener of the source text.
* @param delimiter custom delimiter char
* @return A JSONObject combining the names and values.
* @throws JSONException if a called function fails
*/ */
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x, char delimiter) throws JSONException { public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x, char delimiter) throws JSONException {
JSONArray ja = rowToJSONArray(x, delimiter); JSONArray ja = rowToJSONArray(x, delimiter);
@ -148,8 +157,12 @@ public class CDL {
} }
/** /**
* Same as {@link #rowToString(JSONArray)}, but with a custom delimiter. * Produce a comma delimited text row from a JSONArray. Values containing
* @see #rowToString(JSONArray) * the comma character will be quoted. Troublesome characters may be
* removed.
* @param ja A JSONArray of strings.
* @param delimiter custom delimiter char
* @return A string ending in NEWLINE.
*/ */
public static String rowToString(JSONArray ja, char delimiter) { public static String rowToString(JSONArray ja, char delimiter) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -193,8 +206,12 @@ public class CDL {
} }
/** /**
* Same as {@link #toJSONArray(String)}, but with a custom delimiter. * Produce a JSONArray of JSONObjects from a comma delimited text string,
* @see #toJSONArray(String) * using the first row as a source of names.
* @param string The comma delimited text.
* @param delimiter custom delimiter char
* @return A JSONArray of JSONObjects.
* @throws JSONException if a called function fails
*/ */
public static JSONArray toJSONArray(String string, char delimiter) throws JSONException { public static JSONArray toJSONArray(String string, char delimiter) throws JSONException {
return toJSONArray(new JSONTokener(string), delimiter); return toJSONArray(new JSONTokener(string), delimiter);
@ -212,8 +229,12 @@ public class CDL {
} }
/** /**
* Same as {@link #toJSONArray(JSONTokener)}, but with a custom delimiter. * Produce a JSONArray of JSONObjects from a comma delimited text string,
* @see #toJSONArray(JSONTokener) * using the first row as a source of names.
* @param x The JSONTokener containing the comma delimited text.
* @param delimiter custom delimiter char
* @return A JSONArray of JSONObjects.
* @throws JSONException if a called function fails
*/ */
public static JSONArray toJSONArray(JSONTokener x, char delimiter) throws JSONException { public static JSONArray toJSONArray(JSONTokener x, char delimiter) throws JSONException {
return toJSONArray(rowToJSONArray(x, delimiter), x, delimiter); return toJSONArray(rowToJSONArray(x, delimiter), x, delimiter);
@ -232,8 +253,13 @@ public class CDL {
} }
/** /**
* Same as {@link #toJSONArray(JSONArray, String)}, but with a custom delimiter. * Produce a JSONArray of JSONObjects from a comma delimited text string
* @see #toJSONArray(JSONArray, String) * using a supplied JSONArray as the source of element names.
* @param names A JSONArray of strings.
* @param string The comma delimited text.
* @param delimiter custom delimiter char
* @return A JSONArray of JSONObjects.
* @throws JSONException if a called function fails
*/ */
public static JSONArray toJSONArray(JSONArray names, String string, char delimiter) throws JSONException { public static JSONArray toJSONArray(JSONArray names, String string, char delimiter) throws JSONException {
return toJSONArray(names, new JSONTokener(string), delimiter); return toJSONArray(names, new JSONTokener(string), delimiter);
@ -252,8 +278,13 @@ public class CDL {
} }
/** /**
* Same as {@link #toJSONArray(JSONArray, JSONTokener)}, but with a custom delimiter. * Produce a JSONArray of JSONObjects from a comma delimited text string
* @see #toJSONArray(JSONArray, JSONTokener) * using a supplied JSONArray as the source of element names.
* @param names A JSONArray of strings.
* @param x A JSONTokener of the source text.
* @param delimiter custom delimiter char
* @return A JSONArray of JSONObjects.
* @throws JSONException if a called function fails
*/ */
public static JSONArray toJSONArray(JSONArray names, JSONTokener x, char delimiter) throws JSONException { public static JSONArray toJSONArray(JSONArray names, JSONTokener x, char delimiter) throws JSONException {
if (names == null || names.length() == 0) { if (names == null || names.length() == 0) {
@ -287,8 +318,13 @@ public class CDL {
} }
/** /**
* Same as {@link #toString(JSONArray)}, but with a custom delimiter. * Produce a comma delimited text from a JSONArray of JSONObjects. The
* @see #toString(JSONArray) * first row will be a list of names obtained by inspecting the first
* JSONObject.
* @param ja A JSONArray of JSONObjects.
* @param delimiter custom delimiter char
* @return A comma delimited text.
* @throws JSONException if a called function fails
*/ */
public static String toString(JSONArray ja, char delimiter) throws JSONException { public static String toString(JSONArray ja, char delimiter) throws JSONException {
JSONObject jo = ja.optJSONObject(0); JSONObject jo = ja.optJSONObject(0);
@ -315,8 +351,14 @@ public class CDL {
} }
/** /**
* Same as {@link #toString(JSONArray,JSONArray)}, but with a custom delimiter. * Produce a comma delimited text from a JSONArray of JSONObjects using
* @see #toString(JSONArray,JSONArray) * a provided list of names. The list of names is not included in the
* output.
* @param names A JSONArray of strings.
* @param ja A JSONArray of JSONObjects.
* @param delimiter custom delimiter char
* @return A comma delimited text.
* @throws JSONException if a called function fails
*/ */
public static String toString(JSONArray names, JSONArray ja, char delimiter) throws JSONException { public static String toString(JSONArray names, JSONArray ja, char delimiter) throws JSONException {
if (names == null || names.length() == 0) { if (names == null || names.length() == 0) {