MCPcopy Index your code
hub / github.com/processing/processing / writeInternal

Method writeInternal

core/src/processing/data/JSONArray.java:1197–1237  ·  view source on GitHub ↗

Write the contents of the JSONArray as JSON text to a writer. Warning: This method assumes that the data structure is acyclic. @param indentFactor The number of spaces to add to each level of indentation. Use -1 to specify no indentation and no newlines. @param indent

(Writer writer, int indentFactor, int indent)

Source from the content-addressed store, hash-verified

1195 * @throws RuntimeException
1196 */
1197 protected Writer writeInternal(Writer writer, int indentFactor, int indent) {
1198 try {
1199 boolean commanate = false;
1200 int length = this.size();
1201 writer.write('[');
1202
1203 // Use -1 to signify 'no indent'
1204 int thisFactor = (indentFactor == -1) ? 0 : indentFactor;
1205
1206 if (length == 1) {
1207 JSONObject.writeValue(writer, this.myArrayList.get(0),
1208 indentFactor, indent);
1209// thisFactor, indent);
1210 } else if (length != 0) {
1211 final int newIndent = indent + thisFactor;
1212
1213 for (int i = 0; i < length; i += 1) {
1214 if (commanate) {
1215 writer.write(',');
1216 }
1217 if (indentFactor != -1) {
1218 writer.write('\n');
1219 }
1220 JSONObject.indent(writer, newIndent);
1221// JSONObject.writeValue(writer, this.myArrayList.get(i),
1222// thisFactor, newIndent);
1223 JSONObject.writeValue(writer, this.myArrayList.get(i),
1224 indentFactor, newIndent);
1225 commanate = true;
1226 }
1227 if (indentFactor != -1) {
1228 writer.write('\n');
1229 }
1230 JSONObject.indent(writer, indent);
1231 }
1232 writer.write(']');
1233 return writer;
1234 } catch (IOException e) {
1235 throw new RuntimeException(e);
1236 }
1237 }
1238
1239
1240 /**

Callers 1

formatMethod · 0.95

Calls 5

sizeMethod · 0.95
writeValueMethod · 0.95
indentMethod · 0.95
writeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected