picrate 0.5.0-java → 0.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +1 -1
- data/Rakefile +8 -6
- data/docs/_editors/geany.md +5 -4
- data/docs/_editors/vim.md +6 -0
- data/docs/_includes/head.html +1 -0
- data/docs/_libraries/control_panel.md +2 -2
- data/docs/_libraries/gl_video.md +21 -0
- data/docs/_posts/2018-05-06-getting_started.md +10 -9
- data/docs/_posts/2018-05-06-install_jruby.md +19 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +19 -4
- data/docs/_posts/2018-11-18-building-gem.md +18 -0
- data/docs/_posts/2018-11-27-getting_started_geany.md +38 -0
- data/docs/about.md +21 -10
- data/docs/assets/android-chrome-192x192.png +0 -0
- data/docs/assets/android-chrome-512x512.png +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/geany.png +0 -0
- data/docs/assets/jwishy_picrate.png +0 -0
- data/docs/assets/picrate.svg +251 -0
- data/docs/index.html +8 -14
- data/lib/picrate/runner.rb +6 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +10 -13
- data/mvnw +234 -0
- data/picrate.gemspec +2 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +10 -2
- data/src/main/java/monkstone/ColorUtil.java +11 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -0
- data/src/main/java/monkstone/PicrateLibrary.java +1 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleSlider.java +8 -8
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/Slider.java +3 -3
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/vecmath/AppRender.java +1 -0
- data/src/main/java/monkstone/vecmath/JRender.java +1 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -0
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -0
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +85 -16
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +18 -12
- data/src/main/java/processing/core/PShape.java +1182 -305
- data/src/main/java/processing/core/PStyle.java +1 -1
- data/src/main/java/processing/core/PSurface.java +1 -1
- data/src/main/java/processing/data/FloatDict.java +196 -54
- data/src/main/java/processing/data/FloatList.java +167 -54
- data/src/main/java/processing/data/IntDict.java +211 -56
- data/src/main/java/processing/data/IntList.java +185 -52
- data/src/main/java/processing/data/JSONArray.java +69 -20
- data/src/main/java/processing/data/JSONObject.java +53 -12
- data/src/main/java/processing/data/Sort.java +40 -10
- data/src/main/java/processing/data/StringDict.java +159 -49
- data/src/main/java/processing/data/StringList.java +147 -42
- data/src/main/java/processing/data/Table.java +778 -223
- data/src/main/java/processing/data/TableRow.java +26 -2
- data/src/main/java/processing/data/XML.java +190 -50
- data/src/main/java/processing/event/Event.java +93 -0
- data/src/main/java/processing/event/KeyEvent.java +55 -13
- data/src/main/java/processing/event/MouseEvent.java +77 -1
- data/src/main/java/processing/event/TouchEvent.java +14 -1
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +8 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +228 -66
- data/src/main/java/processing/opengl/LinePath.java +131 -27
- data/src/main/java/processing/opengl/LineStroker.java +30 -5
- data/src/main/java/processing/opengl/PGL.java +4066 -865
- data/src/main/java/processing/opengl/PGraphics2D.java +38 -10
- data/src/main/java/processing/opengl/PGraphics3D.java +38 -6
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +1980 -474
- data/src/main/java/processing/opengl/PJOGL.java +1460 -248
- data/src/main/java/processing/opengl/PShader.java +904 -217
- data/src/main/java/processing/opengl/PShapeOpenGL.java +1811 -487
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +278 -71
- data/src/main/java/processing/opengl/Texture.java +610 -135
- data/src/main/java/processing/opengl/VertexBuffer.java +45 -9
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +13 -6
- data/docs/assets/circle_collisions.png +0 -0
- data/docs/favicon.ico +0 -0
@@ -22,12 +22,15 @@ public class StringList implements Iterable<String> {
|
|
22
22
|
int count;
|
23
23
|
String[] data;
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
/**
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
public StringList() {
|
27
29
|
this(10);
|
28
30
|
}
|
29
31
|
|
30
32
|
/**
|
33
|
+
* @param length
|
31
34
|
* @nowebref
|
32
35
|
*/
|
33
36
|
public StringList(int length) {
|
@@ -35,6 +38,7 @@ public class StringList implements Iterable<String> {
|
|
35
38
|
}
|
36
39
|
|
37
40
|
/**
|
41
|
+
* @param list
|
38
42
|
* @nowebref
|
39
43
|
*/
|
40
44
|
public StringList(String[] list) {
|
@@ -45,8 +49,9 @@ public class StringList implements Iterable<String> {
|
|
45
49
|
|
46
50
|
|
47
51
|
/**
|
48
|
-
* Construct a StringList from a random pile of objects.
|
49
|
-
|
52
|
+
* Construct a StringList from a random pile of objects.Null values will
|
53
|
+
stay null, but all the others will be converted to String values.
|
54
|
+
* @param items
|
50
55
|
*/
|
51
56
|
public StringList(Object... items) {
|
52
57
|
count = items.length;
|
@@ -69,6 +74,7 @@ public class StringList implements Iterable<String> {
|
|
69
74
|
* Create from something iterable, for instance:
|
70
75
|
* StringList list = new StringList(hashMap.keySet());
|
71
76
|
*
|
77
|
+
* @param iter
|
72
78
|
* @nowebref
|
73
79
|
*/
|
74
80
|
public StringList(Iterable<String> iter) {
|
@@ -95,6 +101,7 @@ public class StringList implements Iterable<String> {
|
|
95
101
|
/**
|
96
102
|
* Get the length of the list.
|
97
103
|
*
|
104
|
+
* @return
|
98
105
|
* @webref stringlist:method
|
99
106
|
* @brief Get the length of the list
|
100
107
|
*/
|
@@ -102,8 +109,11 @@ public class StringList implements Iterable<String> {
|
|
102
109
|
return count;
|
103
110
|
}
|
104
111
|
|
105
|
-
|
106
|
-
|
112
|
+
/**
|
113
|
+
*
|
114
|
+
* @param length
|
115
|
+
*/
|
116
|
+
public void resize(int length) {
|
107
117
|
if (length > data.length) {
|
108
118
|
String[] temp = new String[length];
|
109
119
|
System.arraycopy(data, 0, temp, 0, count);
|
@@ -130,6 +140,8 @@ public class StringList implements Iterable<String> {
|
|
130
140
|
/**
|
131
141
|
* Get an entry at a particular index.
|
132
142
|
*
|
143
|
+
* @param index
|
144
|
+
* @return
|
133
145
|
* @webref stringlist:method
|
134
146
|
* @brief Get an entry at a particular index
|
135
147
|
*/
|
@@ -142,10 +154,12 @@ public class StringList implements Iterable<String> {
|
|
142
154
|
|
143
155
|
|
144
156
|
/**
|
145
|
-
* Set the entry at a particular index.
|
146
|
-
|
147
|
-
|
157
|
+
* Set the entry at a particular index.If the index is past the length of
|
158
|
+
the list, it'll expand the list to accommodate, and fill the intermediate
|
159
|
+
entries with 0s.
|
148
160
|
*
|
161
|
+
* @param index
|
162
|
+
* @param what
|
149
163
|
* @webref stringlist:method
|
150
164
|
* @brief Set an entry at a particular index
|
151
165
|
*/
|
@@ -161,13 +175,17 @@ public class StringList implements Iterable<String> {
|
|
161
175
|
}
|
162
176
|
|
163
177
|
|
164
|
-
/** Just an alias for append(), but matches pop()
|
178
|
+
/** Just an alias for append(), but matches pop()
|
179
|
+
* @param value */
|
165
180
|
public void push(String value) {
|
166
181
|
append(value);
|
167
182
|
}
|
168
183
|
|
169
|
-
|
170
|
-
|
184
|
+
/**
|
185
|
+
*
|
186
|
+
* @return
|
187
|
+
*/
|
188
|
+
public String pop() {
|
171
189
|
if (count == 0) {
|
172
190
|
throw new RuntimeException("Can't call pop() on an empty list");
|
173
191
|
}
|
@@ -180,6 +198,8 @@ public class StringList implements Iterable<String> {
|
|
180
198
|
/**
|
181
199
|
* Remove an element from the specified index.
|
182
200
|
*
|
201
|
+
* @param index
|
202
|
+
* @return
|
183
203
|
* @webref stringlist:method
|
184
204
|
* @brief Remove an element from the specified index
|
185
205
|
*/
|
@@ -202,6 +222,12 @@ public class StringList implements Iterable<String> {
|
|
202
222
|
|
203
223
|
|
204
224
|
// Remove the first instance of a particular value and return its index.
|
225
|
+
|
226
|
+
/**
|
227
|
+
*
|
228
|
+
* @param value
|
229
|
+
* @return
|
230
|
+
*/
|
205
231
|
public int removeValue(String value) {
|
206
232
|
if (value == null) {
|
207
233
|
for (int i = 0; i < count; i++) {
|
@@ -222,6 +248,12 @@ public class StringList implements Iterable<String> {
|
|
222
248
|
|
223
249
|
|
224
250
|
// Remove all instances of a particular value and return the count removed.
|
251
|
+
|
252
|
+
/**
|
253
|
+
*
|
254
|
+
* @param value
|
255
|
+
* @return
|
256
|
+
*/
|
225
257
|
public int removeValues(String value) {
|
226
258
|
int ii = 0;
|
227
259
|
if (value == null) {
|
@@ -244,6 +276,13 @@ public class StringList implements Iterable<String> {
|
|
244
276
|
|
245
277
|
|
246
278
|
// replace the first value that matches, return the index that was replaced
|
279
|
+
|
280
|
+
/**
|
281
|
+
*
|
282
|
+
* @param value
|
283
|
+
* @param newValue
|
284
|
+
* @return
|
285
|
+
*/
|
247
286
|
public int replaceValue(String value, String newValue) {
|
248
287
|
if (value == null) {
|
249
288
|
for (int i = 0; i < count; i++) {
|
@@ -265,6 +304,13 @@ public class StringList implements Iterable<String> {
|
|
265
304
|
|
266
305
|
|
267
306
|
// replace all values that match, return the count of those replaced
|
307
|
+
|
308
|
+
/**
|
309
|
+
*
|
310
|
+
* @param value
|
311
|
+
* @param newValue
|
312
|
+
* @return
|
313
|
+
*/
|
268
314
|
public int replaceValues(String value, String newValue) {
|
269
315
|
int changed = 0;
|
270
316
|
if (value == null) {
|
@@ -289,6 +335,7 @@ public class StringList implements Iterable<String> {
|
|
289
335
|
/**
|
290
336
|
* Add a new entry to the list.
|
291
337
|
*
|
338
|
+
* @param value
|
292
339
|
* @webref stringlist:method
|
293
340
|
* @brief Add a new entry to the list
|
294
341
|
*/
|
@@ -299,22 +346,29 @@ public class StringList implements Iterable<String> {
|
|
299
346
|
data[count++] = value;
|
300
347
|
}
|
301
348
|
|
302
|
-
|
303
|
-
|
349
|
+
/**
|
350
|
+
*
|
351
|
+
* @param values
|
352
|
+
*/
|
353
|
+
public void append(String[] values) {
|
304
354
|
for (String v : values) {
|
305
355
|
append(v);
|
306
356
|
}
|
307
357
|
}
|
308
358
|
|
309
|
-
|
310
|
-
|
359
|
+
/**
|
360
|
+
*
|
361
|
+
* @param list
|
362
|
+
*/
|
363
|
+
public void append(StringList list) {
|
311
364
|
for (String v : list.values()) { // will concat the list...
|
312
365
|
append(v);
|
313
366
|
}
|
314
367
|
}
|
315
368
|
|
316
369
|
|
317
|
-
/** Add this value, but only if it's not already in the list.
|
370
|
+
/** Add this value, but only if it's not already in the list.
|
371
|
+
* @param value */
|
318
372
|
public void appendUnique(String value) {
|
319
373
|
if (!hasValue(value)) {
|
320
374
|
append(value);
|
@@ -351,6 +405,12 @@ public class StringList implements Iterable<String> {
|
|
351
405
|
// }
|
352
406
|
// }
|
353
407
|
|
408
|
+
/**
|
409
|
+
*
|
410
|
+
* @param index
|
411
|
+
* @param value
|
412
|
+
*/
|
413
|
+
|
354
414
|
|
355
415
|
public void insert(int index, String value) {
|
356
416
|
insert(index, new String[] { value });
|
@@ -358,6 +418,12 @@ public class StringList implements Iterable<String> {
|
|
358
418
|
|
359
419
|
|
360
420
|
// same as splice
|
421
|
+
|
422
|
+
/**
|
423
|
+
*
|
424
|
+
* @param index
|
425
|
+
* @param values
|
426
|
+
*/
|
361
427
|
public void insert(int index, String[] values) {
|
362
428
|
if (index < 0) {
|
363
429
|
throw new IllegalArgumentException("insert() index cannot be negative: it was " + index);
|
@@ -385,8 +451,12 @@ public class StringList implements Iterable<String> {
|
|
385
451
|
data = temp;
|
386
452
|
}
|
387
453
|
|
388
|
-
|
389
|
-
|
454
|
+
/**
|
455
|
+
*
|
456
|
+
* @param index
|
457
|
+
* @param list
|
458
|
+
*/
|
459
|
+
public void insert(int index, StringList list) {
|
390
460
|
insert(index, list.values());
|
391
461
|
}
|
392
462
|
|
@@ -434,7 +504,9 @@ public class StringList implements Iterable<String> {
|
|
434
504
|
// }
|
435
505
|
|
436
506
|
|
437
|
-
/** Return the first index of a particular value.
|
507
|
+
/** Return the first index of a particular value.
|
508
|
+
* @param what
|
509
|
+
* @return */
|
438
510
|
public int index(String what) {
|
439
511
|
if (what == null) {
|
440
512
|
for (int i = 0; i < count; i++) {
|
@@ -463,6 +535,8 @@ public class StringList implements Iterable<String> {
|
|
463
535
|
// }
|
464
536
|
|
465
537
|
/**
|
538
|
+
* @param value
|
539
|
+
* @return
|
466
540
|
* @webref stringlist:method
|
467
541
|
* @brief Check if a value is a part of the list
|
468
542
|
*/
|
@@ -584,6 +658,7 @@ public class StringList implements Iterable<String> {
|
|
584
658
|
/**
|
585
659
|
* Randomize the list order using the random() function from the specified
|
586
660
|
* sketch, allowing shuffle() to use its current randomSeed() setting.
|
661
|
+
* @param sketch
|
587
662
|
*/
|
588
663
|
public void shuffle(PApplet sketch) {
|
589
664
|
int num = count;
|
@@ -626,8 +701,11 @@ public class StringList implements Iterable<String> {
|
|
626
701
|
}
|
627
702
|
}
|
628
703
|
|
629
|
-
|
630
|
-
|
704
|
+
/**
|
705
|
+
*
|
706
|
+
* @return
|
707
|
+
*/
|
708
|
+
public StringList copy() {
|
631
709
|
StringList outgoing = new StringList(data);
|
632
710
|
outgoing.count = count;
|
633
711
|
return outgoing;
|
@@ -635,17 +713,21 @@ public class StringList implements Iterable<String> {
|
|
635
713
|
|
636
714
|
|
637
715
|
/**
|
638
|
-
* Returns the actual array being used to store the data.
|
639
|
-
|
640
|
-
|
716
|
+
* Returns the actual array being used to store the data.Suitable for
|
717
|
+
iterating with a for() loop, but modifying the list could cause terrible
|
718
|
+
things to happen.
|
719
|
+
* @return
|
641
720
|
*/
|
642
721
|
public String[] values() {
|
643
722
|
crop();
|
644
723
|
return data;
|
645
724
|
}
|
646
725
|
|
647
|
-
|
648
|
-
|
726
|
+
/**
|
727
|
+
*
|
728
|
+
* @return
|
729
|
+
*/
|
730
|
+
@Override
|
649
731
|
public Iterator<String> iterator() {
|
650
732
|
// return valueIterator();
|
651
733
|
// }
|
@@ -684,9 +766,10 @@ public class StringList implements Iterable<String> {
|
|
684
766
|
|
685
767
|
|
686
768
|
/**
|
687
|
-
* Copy values into the specified array.
|
688
|
-
|
769
|
+
* Copy values into the specified array.If the specified array is null or
|
770
|
+
not the same size, a new array will be allocated.
|
689
771
|
* @param array
|
772
|
+
* @return
|
690
773
|
*/
|
691
774
|
public String[] array(String[] array) {
|
692
775
|
if (array == null || array.length != count) {
|
@@ -696,26 +779,37 @@ public class StringList implements Iterable<String> {
|
|
696
779
|
return array;
|
697
780
|
}
|
698
781
|
|
699
|
-
|
700
|
-
|
782
|
+
/**
|
783
|
+
*
|
784
|
+
* @param start
|
785
|
+
* @return
|
786
|
+
*/
|
787
|
+
public StringList getSubset(int start) {
|
701
788
|
return getSubset(start, count - start);
|
702
789
|
}
|
703
790
|
|
704
|
-
|
705
|
-
|
791
|
+
/**
|
792
|
+
*
|
793
|
+
* @param start
|
794
|
+
* @param num
|
795
|
+
* @return
|
796
|
+
*/
|
797
|
+
public StringList getSubset(int start, int num) {
|
706
798
|
String[] subset = new String[num];
|
707
799
|
System.arraycopy(data, start, subset, 0, num);
|
708
800
|
return new StringList(subset);
|
709
801
|
}
|
710
802
|
|
711
803
|
|
712
|
-
/** Get a list of all unique entries.
|
804
|
+
/** Get a list of all unique entries.
|
805
|
+
* @return */
|
713
806
|
public String[] getUnique() {
|
714
807
|
return getTally().keyArray();
|
715
808
|
}
|
716
809
|
|
717
810
|
|
718
|
-
/** Count the number of times each String entry is found in this list.
|
811
|
+
/** Count the number of times each String entry is found in this list.
|
812
|
+
* @return */
|
719
813
|
public IntDict getTally() {
|
720
814
|
IntDict outgoing = new IntDict();
|
721
815
|
for (int i = 0; i < count; i++) {
|
@@ -725,7 +819,8 @@ public class StringList implements Iterable<String> {
|
|
725
819
|
}
|
726
820
|
|
727
821
|
|
728
|
-
/** Create a dictionary associating each entry in this list to its index.
|
822
|
+
/** Create a dictionary associating each entry in this list to its index.
|
823
|
+
* @return */
|
729
824
|
public IntDict getOrder() {
|
730
825
|
IntDict outgoing = new IntDict();
|
731
826
|
for (int i = 0; i < count; i++) {
|
@@ -734,8 +829,12 @@ public class StringList implements Iterable<String> {
|
|
734
829
|
return outgoing;
|
735
830
|
}
|
736
831
|
|
737
|
-
|
738
|
-
|
832
|
+
/**
|
833
|
+
*
|
834
|
+
* @param separator
|
835
|
+
* @return
|
836
|
+
*/
|
837
|
+
public String join(String separator) {
|
739
838
|
if (count == 0) {
|
740
839
|
return "";
|
741
840
|
}
|
@@ -748,8 +847,10 @@ public class StringList implements Iterable<String> {
|
|
748
847
|
return sb.toString();
|
749
848
|
}
|
750
849
|
|
751
|
-
|
752
|
-
|
850
|
+
/**
|
851
|
+
*
|
852
|
+
*/
|
853
|
+
public void print() {
|
753
854
|
for (int i = 0; i < count; i++) {
|
754
855
|
System.out.format("[%d] %s%n", i, data[i]);
|
755
856
|
}
|
@@ -758,6 +859,7 @@ public class StringList implements Iterable<String> {
|
|
758
859
|
|
759
860
|
/**
|
760
861
|
* Return this dictionary as a String in JSON format.
|
862
|
+
* @return
|
761
863
|
*/
|
762
864
|
public String toJSON() {
|
763
865
|
StringList temp = new StringList();
|
@@ -767,8 +869,11 @@ public class StringList implements Iterable<String> {
|
|
767
869
|
return "[ " + temp.join(", ") + " ]";
|
768
870
|
}
|
769
871
|
|
770
|
-
|
771
|
-
|
872
|
+
/**
|
873
|
+
*
|
874
|
+
* @return
|
875
|
+
*/
|
876
|
+
@Override
|
772
877
|
public String toString() {
|
773
878
|
return getClass().getSimpleName() + " size=" + size() + " " + toJSON();
|
774
879
|
}
|
@@ -61,8 +61,16 @@ import processing.core.PConstants;
|
|
61
61
|
* @see TableRow
|
62
62
|
*/
|
63
63
|
public class Table {
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
/**
|
66
|
+
*
|
67
|
+
*/
|
68
|
+
protected int rowCount;
|
69
|
+
|
70
|
+
/**
|
71
|
+
*
|
72
|
+
*/
|
73
|
+
protected int allocCount;
|
66
74
|
|
67
75
|
// protected boolean skipEmptyRows = true;
|
68
76
|
// protected boolean skipCommentLines = true;
|
@@ -70,32 +78,90 @@ public class Table {
|
|
70
78
|
// protected boolean commaSeparatedValues = false;
|
71
79
|
// protected boolean awfulCSV = false;
|
72
80
|
|
81
|
+
/**
|
82
|
+
*
|
83
|
+
*/
|
84
|
+
|
73
85
|
protected String missingString = null;
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
|
87
|
+
/**
|
88
|
+
*
|
89
|
+
*/
|
90
|
+
protected int missingInt = 0;
|
91
|
+
|
92
|
+
/**
|
93
|
+
*
|
94
|
+
*/
|
95
|
+
protected long missingLong = 0;
|
96
|
+
|
97
|
+
/**
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
protected float missingFloat = Float.NaN;
|
101
|
+
|
102
|
+
/**
|
103
|
+
*
|
104
|
+
*/
|
105
|
+
protected double missingDouble = Double.NaN;
|
106
|
+
|
107
|
+
/**
|
108
|
+
*
|
109
|
+
*/
|
110
|
+
protected int missingCategory = -1;
|
79
111
|
|
80
112
|
String[] columnTitles;
|
81
113
|
HashMapBlows[] columnCategories;
|
82
114
|
HashMap<String, Integer> columnIndices;
|
83
115
|
|
84
|
-
|
116
|
+
/**
|
117
|
+
*
|
118
|
+
*/
|
119
|
+
protected Object[] columns; // [column]
|
85
120
|
|
86
121
|
// accessible for advanced users
|
122
|
+
|
123
|
+
/**
|
124
|
+
*
|
125
|
+
*/
|
87
126
|
static public final int STRING = 0;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
127
|
+
|
128
|
+
/**
|
129
|
+
*
|
130
|
+
*/
|
131
|
+
static public final int INT = 1;
|
132
|
+
|
133
|
+
/**
|
134
|
+
*
|
135
|
+
*/
|
136
|
+
static public final int LONG = 2;
|
137
|
+
|
138
|
+
/**
|
139
|
+
*
|
140
|
+
*/
|
141
|
+
static public final int FLOAT = 3;
|
142
|
+
|
143
|
+
/**
|
144
|
+
*
|
145
|
+
*/
|
146
|
+
static public final int DOUBLE = 4;
|
147
|
+
|
148
|
+
/**
|
149
|
+
*
|
150
|
+
*/
|
151
|
+
static public final int CATEGORY = 5;
|
93
152
|
int[] columnTypes;
|
94
153
|
|
95
|
-
|
154
|
+
/**
|
155
|
+
*
|
156
|
+
*/
|
157
|
+
protected RowIterator rowIterator;
|
96
158
|
|
97
159
|
// 0 for doubling each time, otherwise the number of rows to increment on
|
98
160
|
// each expansion.
|
161
|
+
|
162
|
+
/**
|
163
|
+
*
|
164
|
+
*/
|
99
165
|
protected int expandIncrement;
|
100
166
|
|
101
167
|
|
@@ -107,6 +173,8 @@ public class Table {
|
|
107
173
|
}
|
108
174
|
|
109
175
|
/**
|
176
|
+
* @param file
|
177
|
+
* @throws java.io.IOException
|
110
178
|
* @nowebref
|
111
179
|
*/
|
112
180
|
public Table(File file) throws IOException {
|
@@ -118,6 +186,9 @@ public class Table {
|
|
118
186
|
* version that uses a File object; future releases (or data types)
|
119
187
|
* may include additional optimizations here
|
120
188
|
*
|
189
|
+
* @param file
|
190
|
+
* @param options
|
191
|
+
* @throws java.io.IOException
|
121
192
|
* @nowebref
|
122
193
|
*/
|
123
194
|
public Table(File file, String options) throws IOException {
|
@@ -128,6 +199,8 @@ public class Table {
|
|
128
199
|
}
|
129
200
|
|
130
201
|
/**
|
202
|
+
* @param input
|
203
|
+
* @throws java.io.IOException
|
131
204
|
* @nowebref
|
132
205
|
*/
|
133
206
|
public Table(InputStream input) throws IOException {
|
@@ -154,8 +227,11 @@ public class Table {
|
|
154
227
|
parse(input, options);
|
155
228
|
}
|
156
229
|
|
157
|
-
|
158
|
-
|
230
|
+
/**
|
231
|
+
*
|
232
|
+
* @param rows
|
233
|
+
*/
|
234
|
+
public Table(Iterable<TableRow> rows) {
|
159
235
|
init();
|
160
236
|
|
161
237
|
int row = 0;
|
@@ -195,6 +271,7 @@ public class Table {
|
|
195
271
|
|
196
272
|
|
197
273
|
/**
|
274
|
+
* @param rs
|
198
275
|
* @nowebref
|
199
276
|
*/
|
200
277
|
public Table(ResultSet rs) {
|
@@ -254,16 +331,24 @@ public class Table {
|
|
254
331
|
}
|
255
332
|
}
|
256
333
|
|
257
|
-
|
258
|
-
|
334
|
+
/**
|
335
|
+
*
|
336
|
+
* @param input
|
337
|
+
* @param options
|
338
|
+
* @return
|
339
|
+
* @throws IOException
|
340
|
+
*/
|
341
|
+
public Table typedParse(InputStream input, String options) throws IOException {
|
259
342
|
Table table = new Table();
|
260
343
|
table.setColumnTypes(this);
|
261
344
|
table.parse(input, options);
|
262
345
|
return table;
|
263
346
|
}
|
264
347
|
|
265
|
-
|
266
|
-
|
348
|
+
/**
|
349
|
+
*
|
350
|
+
*/
|
351
|
+
protected void init() {
|
267
352
|
columns = new Object[0];
|
268
353
|
columnTypes = new int[0];
|
269
354
|
columnCategories = new HashMapBlows[0];
|
@@ -305,7 +390,14 @@ public class Table {
|
|
305
390
|
static final String[] loadExtensions = { "csv", "tsv", "ods", "bin" };
|
306
391
|
static final String[] saveExtensions = { "csv", "tsv", "ods", "bin", "html" };
|
307
392
|
|
308
|
-
|
393
|
+
/**
|
394
|
+
*
|
395
|
+
* @param loading
|
396
|
+
* @param filename
|
397
|
+
* @param options
|
398
|
+
* @return
|
399
|
+
*/
|
400
|
+
static public String extensionOptions(boolean loading, String filename, String options) {
|
309
401
|
String extension = PApplet.checkExtension(filename);
|
310
402
|
if (extension != null) {
|
311
403
|
for (String possible : loading ? loadExtensions : saveExtensions) {
|
@@ -323,8 +415,13 @@ public class Table {
|
|
323
415
|
return options;
|
324
416
|
}
|
325
417
|
|
326
|
-
|
327
|
-
|
418
|
+
/**
|
419
|
+
*
|
420
|
+
* @param input
|
421
|
+
* @param options
|
422
|
+
* @throws IOException
|
423
|
+
*/
|
424
|
+
protected void parse(InputStream input, String options) throws IOException {
|
328
425
|
// boolean awfulCSV = false;
|
329
426
|
boolean header = false;
|
330
427
|
String extension = null;
|
@@ -400,8 +497,14 @@ public class Table {
|
|
400
497
|
}
|
401
498
|
}
|
402
499
|
|
403
|
-
|
404
|
-
|
500
|
+
/**
|
501
|
+
*
|
502
|
+
* @param reader
|
503
|
+
* @param header
|
504
|
+
* @param tsv
|
505
|
+
* @throws IOException
|
506
|
+
*/
|
507
|
+
protected void parseBasic(BufferedReader reader,
|
405
508
|
boolean header, boolean tsv) throws IOException {
|
406
509
|
String line = null;
|
407
510
|
int row = 0;
|
@@ -743,10 +846,12 @@ public class Table {
|
|
743
846
|
|
744
847
|
/**
|
745
848
|
* Parse a line of text as comma-separated values, returning each value as
|
746
|
-
* one entry in an array of String objects.
|
747
|
-
|
849
|
+
* one entry in an array of String objects.Remove quotes from entries that
|
850
|
+
begin and end with them, and convert 'escaped' quotes to actual quotes.
|
748
851
|
* @param line line of text to be parsed
|
852
|
+
* @param reader
|
749
853
|
* @return an array of the individual values formerly separated by commas
|
854
|
+
* @throws java.io.IOException
|
750
855
|
*/
|
751
856
|
protected String[] splitLineCSV(String line, BufferedReader reader) throws IOException {
|
752
857
|
if (csl == null) {
|
@@ -840,8 +945,13 @@ public class Table {
|
|
840
945
|
return null;
|
841
946
|
}
|
842
947
|
|
843
|
-
|
844
|
-
|
948
|
+
/**
|
949
|
+
*
|
950
|
+
* @param input
|
951
|
+
* @param worksheet
|
952
|
+
* @param header
|
953
|
+
*/
|
954
|
+
protected void odsParse(InputStream input, String worksheet, boolean header) {
|
845
955
|
try {
|
846
956
|
InputStream contentStream = odsFindContentXML(input);
|
847
957
|
XML xml = new XML(contentStream);
|
@@ -1027,7 +1137,9 @@ public class Table {
|
|
1027
1137
|
// because that's passed to the constructor parameter (inserted by the
|
1028
1138
|
// compiler) of an inner class by the runtime.
|
1029
1139
|
|
1030
|
-
/** incomplete, do not use
|
1140
|
+
/** incomplete, do not use
|
1141
|
+
* @param enclosingObject
|
1142
|
+
* @param fieldName */
|
1031
1143
|
public void parseInto(Object enclosingObject, String fieldName) {
|
1032
1144
|
Class<?> target = null;
|
1033
1145
|
Object outgoing = null;
|
@@ -1170,14 +1282,25 @@ public class Table {
|
|
1170
1282
|
}
|
1171
1283
|
}
|
1172
1284
|
|
1173
|
-
|
1174
|
-
|
1285
|
+
/**
|
1286
|
+
*
|
1287
|
+
* @param file
|
1288
|
+
* @param options
|
1289
|
+
* @return
|
1290
|
+
* @throws IOException
|
1291
|
+
*/
|
1292
|
+
public boolean save(File file, String options) throws IOException {
|
1175
1293
|
return save(PApplet.createOutput(file),
|
1176
1294
|
Table.extensionOptions(false, file.getName(), options));
|
1177
1295
|
}
|
1178
1296
|
|
1179
|
-
|
1180
|
-
|
1297
|
+
/**
|
1298
|
+
*
|
1299
|
+
* @param output
|
1300
|
+
* @param options
|
1301
|
+
* @return
|
1302
|
+
*/
|
1303
|
+
public boolean save(OutputStream output, String options) {
|
1181
1304
|
PrintWriter writer = PApplet.createWriter(output);
|
1182
1305
|
String extension = null;
|
1183
1306
|
if (options == null) {
|
@@ -1225,8 +1348,11 @@ public class Table {
|
|
1225
1348
|
return true;
|
1226
1349
|
}
|
1227
1350
|
|
1228
|
-
|
1229
|
-
|
1351
|
+
/**
|
1352
|
+
*
|
1353
|
+
* @param writer
|
1354
|
+
*/
|
1355
|
+
protected void writeTSV(PrintWriter writer) {
|
1230
1356
|
if (columnTitles != null) {
|
1231
1357
|
for (int col = 0; col < columns.length; col++) {
|
1232
1358
|
if (col != 0) {
|
@@ -1255,8 +1381,11 @@ public class Table {
|
|
1255
1381
|
writer.flush();
|
1256
1382
|
}
|
1257
1383
|
|
1258
|
-
|
1259
|
-
|
1384
|
+
/**
|
1385
|
+
*
|
1386
|
+
* @param writer
|
1387
|
+
*/
|
1388
|
+
protected void writeCSV(PrintWriter writer) {
|
1260
1389
|
if (columnTitles != null) {
|
1261
1390
|
for (int col = 0; col < getColumnCount(); col++) {
|
1262
1391
|
if (col != 0) {
|
@@ -1292,8 +1421,12 @@ public class Table {
|
|
1292
1421
|
writer.flush();
|
1293
1422
|
}
|
1294
1423
|
|
1295
|
-
|
1296
|
-
|
1424
|
+
/**
|
1425
|
+
*
|
1426
|
+
* @param writer
|
1427
|
+
* @param entry
|
1428
|
+
*/
|
1429
|
+
protected void writeEntryCSV(PrintWriter writer, String entry) {
|
1297
1430
|
if (entry != null) {
|
1298
1431
|
if (entry.indexOf('\"') != -1) { // convert quotes to double quotes
|
1299
1432
|
char[] c = entry.toCharArray();
|
@@ -1330,8 +1463,11 @@ public class Table {
|
|
1330
1463
|
}
|
1331
1464
|
}
|
1332
1465
|
|
1333
|
-
|
1334
|
-
|
1466
|
+
/**
|
1467
|
+
*
|
1468
|
+
* @param writer
|
1469
|
+
*/
|
1470
|
+
protected void writeHTML(PrintWriter writer) {
|
1335
1471
|
writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">");
|
1336
1472
|
// writer.println("<!DOCTYPE html>");
|
1337
1473
|
// writer.println("<meta charset=\"utf-8\">");
|
@@ -1380,8 +1516,12 @@ public class Table {
|
|
1380
1516
|
writer.flush();
|
1381
1517
|
}
|
1382
1518
|
|
1383
|
-
|
1384
|
-
|
1519
|
+
/**
|
1520
|
+
*
|
1521
|
+
* @param writer
|
1522
|
+
* @param entry
|
1523
|
+
*/
|
1524
|
+
protected void writeEntryHTML(PrintWriter writer, String entry) {
|
1385
1525
|
//char[] chars = entry.toCharArray();
|
1386
1526
|
for (char c : entry.toCharArray()) { //chars) {
|
1387
1527
|
if (c == '<') {
|
@@ -1406,8 +1546,12 @@ public class Table {
|
|
1406
1546
|
}
|
1407
1547
|
}
|
1408
1548
|
|
1409
|
-
|
1410
|
-
|
1549
|
+
/**
|
1550
|
+
*
|
1551
|
+
* @param os
|
1552
|
+
* @throws IOException
|
1553
|
+
*/
|
1554
|
+
protected void saveODS(OutputStream os) throws IOException {
|
1411
1555
|
ZipOutputStream zos = new ZipOutputStream(os);
|
1412
1556
|
|
1413
1557
|
final String xmlHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
@@ -1607,8 +1751,12 @@ public class Table {
|
|
1607
1751
|
}
|
1608
1752
|
}
|
1609
1753
|
|
1610
|
-
|
1611
|
-
|
1754
|
+
/**
|
1755
|
+
*
|
1756
|
+
* @param os
|
1757
|
+
* @throws IOException
|
1758
|
+
*/
|
1759
|
+
protected void saveBinary(OutputStream os) throws IOException {
|
1612
1760
|
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(os));
|
1613
1761
|
output.writeInt(0x9007AB1E); // version
|
1614
1762
|
output.writeInt(getRowCount());
|
@@ -1683,8 +1831,12 @@ public class Table {
|
|
1683
1831
|
output.close();
|
1684
1832
|
}
|
1685
1833
|
|
1686
|
-
|
1687
|
-
|
1834
|
+
/**
|
1835
|
+
*
|
1836
|
+
* @param is
|
1837
|
+
* @throws IOException
|
1838
|
+
*/
|
1839
|
+
protected void loadBinary(InputStream is) throws IOException {
|
1688
1840
|
DataInputStream input = new DataInputStream(new BufferedInputStream(is));
|
1689
1841
|
|
1690
1842
|
int magic = input.readInt();
|
@@ -1805,24 +1957,37 @@ public class Table {
|
|
1805
1957
|
|
1806
1958
|
|
1807
1959
|
/**
|
1960
|
+
* @param title
|
1808
1961
|
* @param type the type to be used for the new column: INT, LONG, FLOAT, DOUBLE, or STRING
|
1809
1962
|
*/
|
1810
1963
|
public void addColumn(String title, int type) {
|
1811
1964
|
insertColumn(columns.length, title, type);
|
1812
1965
|
}
|
1813
1966
|
|
1814
|
-
|
1815
|
-
|
1967
|
+
/**
|
1968
|
+
*
|
1969
|
+
* @param index
|
1970
|
+
*/
|
1971
|
+
public void insertColumn(int index) {
|
1816
1972
|
insertColumn(index, null, STRING);
|
1817
1973
|
}
|
1818
1974
|
|
1819
|
-
|
1820
|
-
|
1975
|
+
/**
|
1976
|
+
*
|
1977
|
+
* @param index
|
1978
|
+
* @param title
|
1979
|
+
*/
|
1980
|
+
public void insertColumn(int index, String title) {
|
1821
1981
|
insertColumn(index, title, STRING);
|
1822
1982
|
}
|
1823
1983
|
|
1824
|
-
|
1825
|
-
|
1984
|
+
/**
|
1985
|
+
*
|
1986
|
+
* @param index
|
1987
|
+
* @param title
|
1988
|
+
* @param type
|
1989
|
+
*/
|
1990
|
+
public void insertColumn(int index, String title, int type) {
|
1826
1991
|
if (title != null && columnTitles == null) {
|
1827
1992
|
columnTitles = new String[columns.length];
|
1828
1993
|
}
|
@@ -1906,6 +2071,7 @@ public class Table {
|
|
1906
2071
|
|
1907
2072
|
|
1908
2073
|
/**
|
2074
|
+
* @return
|
1909
2075
|
* @webref table:method
|
1910
2076
|
* @brief Gets the number of columns in a table
|
1911
2077
|
* @see Table#getRowCount()
|
@@ -1939,8 +2105,12 @@ public class Table {
|
|
1939
2105
|
}
|
1940
2106
|
}
|
1941
2107
|
|
1942
|
-
|
1943
|
-
|
2108
|
+
/**
|
2109
|
+
*
|
2110
|
+
* @param columnName
|
2111
|
+
* @param columnType
|
2112
|
+
*/
|
2113
|
+
public void setColumnType(String columnName, String columnType) {
|
1944
2114
|
setColumnType(checkColumnIndex(columnName), columnType);
|
1945
2115
|
}
|
1946
2116
|
|
@@ -1976,8 +2146,12 @@ public class Table {
|
|
1976
2146
|
setColumnType(column, parseColumnType(columnType));
|
1977
2147
|
}
|
1978
2148
|
|
1979
|
-
|
1980
|
-
|
2149
|
+
/**
|
2150
|
+
*
|
2151
|
+
* @param columnName
|
2152
|
+
* @param newType
|
2153
|
+
*/
|
2154
|
+
public void setColumnType(String columnName, int newType) {
|
1981
2155
|
setColumnType(checkColumnIndex(columnName), newType);
|
1982
2156
|
}
|
1983
2157
|
|
@@ -2066,6 +2240,7 @@ public class Table {
|
|
2066
2240
|
|
2067
2241
|
/**
|
2068
2242
|
* Set the entire table to a specific data type.
|
2243
|
+
* @param type
|
2069
2244
|
*/
|
2070
2245
|
public void setTableType(String type) {
|
2071
2246
|
for (int col = 0; col < getColumnCount(); col++) {
|
@@ -2073,8 +2248,11 @@ public class Table {
|
|
2073
2248
|
}
|
2074
2249
|
}
|
2075
2250
|
|
2076
|
-
|
2077
|
-
|
2251
|
+
/**
|
2252
|
+
*
|
2253
|
+
* @param types
|
2254
|
+
*/
|
2255
|
+
public void setColumnTypes(int[] types) {
|
2078
2256
|
ensureColumn(types.length - 1);
|
2079
2257
|
for (int col = 0; col < types.length; col++) {
|
2080
2258
|
setColumnType(col, types[col]);
|
@@ -2127,19 +2305,28 @@ public class Table {
|
|
2127
2305
|
}
|
2128
2306
|
}
|
2129
2307
|
|
2130
|
-
|
2131
|
-
|
2308
|
+
/**
|
2309
|
+
*
|
2310
|
+
* @param columnName
|
2311
|
+
* @return
|
2312
|
+
*/
|
2313
|
+
public int getColumnType(String columnName) {
|
2132
2314
|
return getColumnType(getColumnIndex(columnName));
|
2133
2315
|
}
|
2134
2316
|
|
2135
2317
|
|
2136
|
-
/** Returns one of Table.STRING, Table.INT, etc...
|
2318
|
+
/** Returns one of Table.STRING, Table.INT, etc...
|
2319
|
+
* @param column
|
2320
|
+
* @return */
|
2137
2321
|
public int getColumnType(int column) {
|
2138
2322
|
return columnTypes[column];
|
2139
2323
|
}
|
2140
2324
|
|
2141
|
-
|
2142
|
-
|
2325
|
+
/**
|
2326
|
+
*
|
2327
|
+
* @return
|
2328
|
+
*/
|
2329
|
+
public int[] getColumnTypes() {
|
2143
2330
|
return columnTypes;
|
2144
2331
|
}
|
2145
2332
|
|
@@ -2148,8 +2335,8 @@ public class Table {
|
|
2148
2335
|
|
2149
2336
|
|
2150
2337
|
/**
|
2151
|
-
* Remove the first row from the data set, and use it as the column titles.
|
2152
|
-
|
2338
|
+
* Remove the first row from the data set, and use it as the column titles.Use loadTable("table.csv", "header") instead.
|
2339
|
+
* @return
|
2153
2340
|
*/
|
2154
2341
|
@Deprecated
|
2155
2342
|
public String[] removeTitleRow() {
|
@@ -2159,8 +2346,11 @@ public class Table {
|
|
2159
2346
|
return titles;
|
2160
2347
|
}
|
2161
2348
|
|
2162
|
-
|
2163
|
-
|
2349
|
+
/**
|
2350
|
+
*
|
2351
|
+
* @param titles
|
2352
|
+
*/
|
2353
|
+
public void setColumnTitles(String[] titles) {
|
2164
2354
|
if (titles != null) {
|
2165
2355
|
ensureColumn(titles.length - 1);
|
2166
2356
|
}
|
@@ -2168,8 +2358,12 @@ public class Table {
|
|
2168
2358
|
columnIndices = null; // remove the cache
|
2169
2359
|
}
|
2170
2360
|
|
2171
|
-
|
2172
|
-
|
2361
|
+
/**
|
2362
|
+
*
|
2363
|
+
* @param column
|
2364
|
+
* @param title
|
2365
|
+
*/
|
2366
|
+
public void setColumnTitle(int column, String title) {
|
2173
2367
|
ensureColumn(column);
|
2174
2368
|
if (columnTitles == null) {
|
2175
2369
|
columnTitles = new String[getColumnCount()];
|
@@ -2178,23 +2372,37 @@ public class Table {
|
|
2178
2372
|
columnIndices = null; // reset these fellas
|
2179
2373
|
}
|
2180
2374
|
|
2181
|
-
|
2182
|
-
|
2375
|
+
/**
|
2376
|
+
*
|
2377
|
+
* @return
|
2378
|
+
*/
|
2379
|
+
public boolean hasColumnTitles() {
|
2183
2380
|
return columnTitles != null;
|
2184
2381
|
}
|
2185
2382
|
|
2186
|
-
|
2187
|
-
|
2383
|
+
/**
|
2384
|
+
*
|
2385
|
+
* @return
|
2386
|
+
*/
|
2387
|
+
public String[] getColumnTitles() {
|
2188
2388
|
return columnTitles;
|
2189
2389
|
}
|
2190
2390
|
|
2191
|
-
|
2192
|
-
|
2391
|
+
/**
|
2392
|
+
*
|
2393
|
+
* @param col
|
2394
|
+
* @return
|
2395
|
+
*/
|
2396
|
+
public String getColumnTitle(int col) {
|
2193
2397
|
return (columnTitles == null) ? null : columnTitles[col];
|
2194
2398
|
}
|
2195
2399
|
|
2196
|
-
|
2197
|
-
|
2400
|
+
/**
|
2401
|
+
*
|
2402
|
+
* @param columnName
|
2403
|
+
* @return
|
2404
|
+
*/
|
2405
|
+
public int getColumnIndex(String columnName) {
|
2198
2406
|
return getColumnIndex(columnName, true);
|
2199
2407
|
}
|
2200
2408
|
|
@@ -2254,6 +2462,7 @@ public class Table {
|
|
2254
2462
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2255
2463
|
|
2256
2464
|
/**
|
2465
|
+
* @return
|
2257
2466
|
* @webref table:method
|
2258
2467
|
* @brief Gets the number of rows in a table
|
2259
2468
|
* @see Table#getColumnCount()
|
@@ -2262,8 +2471,11 @@ public class Table {
|
|
2262
2471
|
return rowCount;
|
2263
2472
|
}
|
2264
2473
|
|
2265
|
-
|
2266
|
-
|
2474
|
+
/**
|
2475
|
+
*
|
2476
|
+
* @return
|
2477
|
+
*/
|
2478
|
+
public int lastRowIndex() {
|
2267
2479
|
return getRowCount() - 1;
|
2268
2480
|
}
|
2269
2481
|
|
@@ -2278,8 +2490,11 @@ public class Table {
|
|
2278
2490
|
setRowCount(0);
|
2279
2491
|
}
|
2280
2492
|
|
2281
|
-
|
2282
|
-
|
2493
|
+
/**
|
2494
|
+
*
|
2495
|
+
* @param newCount
|
2496
|
+
*/
|
2497
|
+
public void setRowCount(int newCount) {
|
2283
2498
|
if (newCount != rowCount) {
|
2284
2499
|
if (newCount > 1000000) {
|
2285
2500
|
System.out.print("Note: setting maximum row count to " + PApplet.nfc(newCount));
|
@@ -2312,6 +2527,7 @@ public class Table {
|
|
2312
2527
|
|
2313
2528
|
|
2314
2529
|
/**
|
2530
|
+
* @return
|
2315
2531
|
* @webref table:method
|
2316
2532
|
* @brief Adds a row to a table
|
2317
2533
|
* @see Table#removeRow(int)
|
@@ -2326,13 +2542,19 @@ public class Table {
|
|
2326
2542
|
|
2327
2543
|
/**
|
2328
2544
|
* @param source a reference to the original row to be duplicated
|
2545
|
+
* @return
|
2329
2546
|
*/
|
2330
2547
|
public TableRow addRow(TableRow source) {
|
2331
2548
|
return setRow(rowCount, source);
|
2332
2549
|
}
|
2333
2550
|
|
2334
|
-
|
2335
|
-
|
2551
|
+
/**
|
2552
|
+
*
|
2553
|
+
* @param row
|
2554
|
+
* @param source
|
2555
|
+
* @return
|
2556
|
+
*/
|
2557
|
+
public TableRow setRow(int row, TableRow source) {
|
2336
2558
|
// Make sure there are enough columns to add this data
|
2337
2559
|
ensureBounds(row, source.getColumnCount() - 1);
|
2338
2560
|
|
@@ -2370,6 +2592,8 @@ public class Table {
|
|
2370
2592
|
|
2371
2593
|
|
2372
2594
|
/**
|
2595
|
+
* @param columnData
|
2596
|
+
* @return
|
2373
2597
|
* @nowebref
|
2374
2598
|
*/
|
2375
2599
|
public TableRow addRow(Object[] columnData) {
|
@@ -2377,8 +2601,11 @@ public class Table {
|
|
2377
2601
|
return new RowPointer(this, rowCount - 1);
|
2378
2602
|
}
|
2379
2603
|
|
2380
|
-
|
2381
|
-
|
2604
|
+
/**
|
2605
|
+
*
|
2606
|
+
* @param source
|
2607
|
+
*/
|
2608
|
+
public void addRows(Table source) {
|
2382
2609
|
int index = getRowCount();
|
2383
2610
|
setRowCount(index + source.getRowCount());
|
2384
2611
|
for (TableRow row : source.rows()) {
|
@@ -2386,8 +2613,12 @@ public class Table {
|
|
2386
2613
|
}
|
2387
2614
|
}
|
2388
2615
|
|
2389
|
-
|
2390
|
-
|
2616
|
+
/**
|
2617
|
+
*
|
2618
|
+
* @param insert
|
2619
|
+
* @param columnData
|
2620
|
+
*/
|
2621
|
+
public void insertRow(int insert, Object[] columnData) {
|
2391
2622
|
for (int col = 0; col < columns.length; col++) {
|
2392
2623
|
switch (columnTypes[col]) {
|
2393
2624
|
case CATEGORY:
|
@@ -2548,6 +2779,13 @@ public class Table {
|
|
2548
2779
|
}
|
2549
2780
|
*/
|
2550
2781
|
|
2782
|
+
/**
|
2783
|
+
*
|
2784
|
+
* @param row
|
2785
|
+
* @param pieces
|
2786
|
+
*/
|
2787
|
+
|
2788
|
+
|
2551
2789
|
|
2552
2790
|
public void setRow(int row, Object[] pieces) {
|
2553
2791
|
ensureBounds(row, pieces.length - 1);
|
@@ -2557,8 +2795,13 @@ public class Table {
|
|
2557
2795
|
}
|
2558
2796
|
}
|
2559
2797
|
|
2560
|
-
|
2561
|
-
|
2798
|
+
/**
|
2799
|
+
*
|
2800
|
+
* @param row
|
2801
|
+
* @param col
|
2802
|
+
* @param piece
|
2803
|
+
*/
|
2804
|
+
protected void setRowCol(int row, int col, Object piece) {
|
2562
2805
|
switch (columnTypes[col]) {
|
2563
2806
|
case STRING:
|
2564
2807
|
String[] stringData = (String[]) columns[col];
|
@@ -2642,6 +2885,7 @@ public class Table {
|
|
2642
2885
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2643
2886
|
|
2644
2887
|
/**
|
2888
|
+
* @return
|
2645
2889
|
* @webref table:method
|
2646
2890
|
* @brief Gets a row from a table
|
2647
2891
|
* @param row ID number of the row to get
|
@@ -2658,9 +2902,9 @@ public class Table {
|
|
2658
2902
|
|
2659
2903
|
/**
|
2660
2904
|
* Note that this one iterator instance is shared by any calls to iterate
|
2661
|
-
* the rows of this table.
|
2662
|
-
* If you want to iterate in a multi-threaded manner, don't use the iterator.
|
2905
|
+
* the rows of this table.This is very efficient, but not thread-safe. If you want to iterate in a multi-threaded manner, don't use the iterator.
|
2663
2906
|
*
|
2907
|
+
* @return
|
2664
2908
|
* @webref table:method
|
2665
2909
|
* @brief Gets multiple rows from a table
|
2666
2910
|
* @see Table#getRow(int)
|
@@ -2683,6 +2927,8 @@ public class Table {
|
|
2683
2927
|
}
|
2684
2928
|
|
2685
2929
|
/**
|
2930
|
+
* @param indices
|
2931
|
+
* @return
|
2686
2932
|
* @nowebref
|
2687
2933
|
*/
|
2688
2934
|
public Iterable<TableRow> rows(final int[] indices) {
|
@@ -3049,6 +3295,7 @@ public class Table {
|
|
3049
3295
|
|
3050
3296
|
|
3051
3297
|
/**
|
3298
|
+
* @return
|
3052
3299
|
* @webref table:method
|
3053
3300
|
* @brief Get an integer value from the specified row and column
|
3054
3301
|
* @param row ID number of the row to reference
|
@@ -3073,14 +3320,19 @@ public class Table {
|
|
3073
3320
|
}
|
3074
3321
|
|
3075
3322
|
/**
|
3323
|
+
* @param row
|
3076
3324
|
* @param columnName title of the column to reference
|
3325
|
+
* @return
|
3077
3326
|
*/
|
3078
3327
|
public int getInt(int row, String columnName) {
|
3079
3328
|
return getInt(row, getColumnIndex(columnName));
|
3080
3329
|
}
|
3081
3330
|
|
3082
|
-
|
3083
|
-
|
3331
|
+
/**
|
3332
|
+
*
|
3333
|
+
* @param value
|
3334
|
+
*/
|
3335
|
+
public void setMissingInt(int value) {
|
3084
3336
|
missingInt = value;
|
3085
3337
|
}
|
3086
3338
|
|
@@ -3114,21 +3366,30 @@ public class Table {
|
|
3114
3366
|
}
|
3115
3367
|
|
3116
3368
|
/**
|
3369
|
+
* @param row
|
3117
3370
|
* @param columnName title of the target column
|
3371
|
+
* @param value
|
3118
3372
|
*/
|
3119
3373
|
public void setInt(int row, String columnName, int value) {
|
3120
3374
|
setInt(row, getColumnIndex(columnName), value);
|
3121
3375
|
}
|
3122
3376
|
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3377
|
+
/**
|
3378
|
+
*
|
3379
|
+
* @param name
|
3380
|
+
* @return
|
3381
|
+
*/
|
3382
|
+
public int[] getIntColumn(String name) {
|
3126
3383
|
int col = getColumnIndex(name);
|
3127
3384
|
return (col == -1) ? null : getIntColumn(col);
|
3128
3385
|
}
|
3129
3386
|
|
3130
|
-
|
3131
|
-
|
3387
|
+
/**
|
3388
|
+
*
|
3389
|
+
* @param col
|
3390
|
+
* @return
|
3391
|
+
*/
|
3392
|
+
public int[] getIntColumn(int col) {
|
3132
3393
|
int[] outgoing = new int[rowCount];
|
3133
3394
|
for (int row = 0; row < rowCount; row++) {
|
3134
3395
|
outgoing[row] = getInt(row, col);
|
@@ -3136,8 +3397,12 @@ public class Table {
|
|
3136
3397
|
return outgoing;
|
3137
3398
|
}
|
3138
3399
|
|
3139
|
-
|
3140
|
-
|
3400
|
+
/**
|
3401
|
+
*
|
3402
|
+
* @param row
|
3403
|
+
* @return
|
3404
|
+
*/
|
3405
|
+
public int[] getIntRow(int row) {
|
3141
3406
|
int[] outgoing = new int[columns.length];
|
3142
3407
|
for (int col = 0; col < columns.length; col++) {
|
3143
3408
|
outgoing[col] = getInt(row, col);
|
@@ -3148,6 +3413,13 @@ public class Table {
|
|
3148
3413
|
|
3149
3414
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
3150
3415
|
|
3416
|
+
/**
|
3417
|
+
*
|
3418
|
+
* @param row
|
3419
|
+
* @param column
|
3420
|
+
* @return
|
3421
|
+
*/
|
3422
|
+
|
3151
3423
|
|
3152
3424
|
public long getLong(int row, int column) {
|
3153
3425
|
checkBounds(row, column);
|
@@ -3166,18 +3438,31 @@ public class Table {
|
|
3166
3438
|
}
|
3167
3439
|
}
|
3168
3440
|
|
3169
|
-
|
3170
|
-
|
3441
|
+
/**
|
3442
|
+
*
|
3443
|
+
* @param row
|
3444
|
+
* @param columnName
|
3445
|
+
* @return
|
3446
|
+
*/
|
3447
|
+
public long getLong(int row, String columnName) {
|
3171
3448
|
return getLong(row, getColumnIndex(columnName));
|
3172
3449
|
}
|
3173
3450
|
|
3174
|
-
|
3175
|
-
|
3451
|
+
/**
|
3452
|
+
*
|
3453
|
+
* @param value
|
3454
|
+
*/
|
3455
|
+
public void setMissingLong(long value) {
|
3176
3456
|
missingLong = value;
|
3177
3457
|
}
|
3178
3458
|
|
3179
|
-
|
3180
|
-
|
3459
|
+
/**
|
3460
|
+
*
|
3461
|
+
* @param row
|
3462
|
+
* @param column
|
3463
|
+
* @param value
|
3464
|
+
*/
|
3465
|
+
public void setLong(int row, int column, long value) {
|
3181
3466
|
if (columnTypes[column] == STRING) {
|
3182
3467
|
setString(row, column, String.valueOf(value));
|
3183
3468
|
|
@@ -3191,19 +3476,32 @@ public class Table {
|
|
3191
3476
|
}
|
3192
3477
|
}
|
3193
3478
|
|
3194
|
-
|
3195
|
-
|
3479
|
+
/**
|
3480
|
+
*
|
3481
|
+
* @param row
|
3482
|
+
* @param columnName
|
3483
|
+
* @param value
|
3484
|
+
*/
|
3485
|
+
public void setLong(int row, String columnName, long value) {
|
3196
3486
|
setLong(row, getColumnIndex(columnName), value);
|
3197
3487
|
}
|
3198
3488
|
|
3199
|
-
|
3200
|
-
|
3489
|
+
/**
|
3490
|
+
*
|
3491
|
+
* @param name
|
3492
|
+
* @return
|
3493
|
+
*/
|
3494
|
+
public long[] getLongColumn(String name) {
|
3201
3495
|
int col = getColumnIndex(name);
|
3202
3496
|
return (col == -1) ? null : getLongColumn(col);
|
3203
3497
|
}
|
3204
3498
|
|
3205
|
-
|
3206
|
-
|
3499
|
+
/**
|
3500
|
+
*
|
3501
|
+
* @param col
|
3502
|
+
* @return
|
3503
|
+
*/
|
3504
|
+
public long[] getLongColumn(int col) {
|
3207
3505
|
long[] outgoing = new long[rowCount];
|
3208
3506
|
for (int row = 0; row < rowCount; row++) {
|
3209
3507
|
outgoing[row] = getLong(row, col);
|
@@ -3211,8 +3509,12 @@ public class Table {
|
|
3211
3509
|
return outgoing;
|
3212
3510
|
}
|
3213
3511
|
|
3214
|
-
|
3215
|
-
|
3512
|
+
/**
|
3513
|
+
*
|
3514
|
+
* @param row
|
3515
|
+
* @return
|
3516
|
+
*/
|
3517
|
+
public long[] getLongRow(int row) {
|
3216
3518
|
long[] outgoing = new long[columns.length];
|
3217
3519
|
for (int col = 0; col < columns.length; col++) {
|
3218
3520
|
outgoing[col] = getLong(row, col);
|
@@ -3225,10 +3527,11 @@ public class Table {
|
|
3225
3527
|
|
3226
3528
|
|
3227
3529
|
/**
|
3228
|
-
* Get a float value from the specified row and column.
|
3229
|
-
|
3230
|
-
|
3530
|
+
* Get a float value from the specified row and column.If the value is null
|
3531
|
+
or not parseable as a float, the "missing" value is returned. By default,
|
3532
|
+
this is Float.NaN, but can be controlled with setMissingFloat().
|
3231
3533
|
*
|
3534
|
+
* @return
|
3232
3535
|
* @webref table:method
|
3233
3536
|
* @brief Get a float value from the specified row and column
|
3234
3537
|
* @param row ID number of the row to reference
|
@@ -3254,14 +3557,19 @@ public class Table {
|
|
3254
3557
|
}
|
3255
3558
|
|
3256
3559
|
/**
|
3560
|
+
* @param row
|
3257
3561
|
* @param columnName title of the column to reference
|
3562
|
+
* @return
|
3258
3563
|
*/
|
3259
3564
|
public float getFloat(int row, String columnName) {
|
3260
3565
|
return getFloat(row, getColumnIndex(columnName));
|
3261
3566
|
}
|
3262
3567
|
|
3263
|
-
|
3264
|
-
|
3568
|
+
/**
|
3569
|
+
*
|
3570
|
+
* @param value
|
3571
|
+
*/
|
3572
|
+
public void setMissingFloat(float value) {
|
3265
3573
|
missingFloat = value;
|
3266
3574
|
}
|
3267
3575
|
|
@@ -3294,20 +3602,30 @@ public class Table {
|
|
3294
3602
|
}
|
3295
3603
|
|
3296
3604
|
/**
|
3605
|
+
* @param row
|
3297
3606
|
* @param columnName title of the target column
|
3607
|
+
* @param value
|
3298
3608
|
*/
|
3299
3609
|
public void setFloat(int row, String columnName, float value) {
|
3300
3610
|
setFloat(row, getColumnIndex(columnName), value);
|
3301
3611
|
}
|
3302
3612
|
|
3303
|
-
|
3304
|
-
|
3613
|
+
/**
|
3614
|
+
*
|
3615
|
+
* @param name
|
3616
|
+
* @return
|
3617
|
+
*/
|
3618
|
+
public float[] getFloatColumn(String name) {
|
3305
3619
|
int col = getColumnIndex(name);
|
3306
3620
|
return (col == -1) ? null : getFloatColumn(col);
|
3307
3621
|
}
|
3308
3622
|
|
3309
|
-
|
3310
|
-
|
3623
|
+
/**
|
3624
|
+
*
|
3625
|
+
* @param col
|
3626
|
+
* @return
|
3627
|
+
*/
|
3628
|
+
public float[] getFloatColumn(int col) {
|
3311
3629
|
float[] outgoing = new float[rowCount];
|
3312
3630
|
for (int row = 0; row < rowCount; row++) {
|
3313
3631
|
outgoing[row] = getFloat(row, col);
|
@@ -3315,8 +3633,12 @@ public class Table {
|
|
3315
3633
|
return outgoing;
|
3316
3634
|
}
|
3317
3635
|
|
3318
|
-
|
3319
|
-
|
3636
|
+
/**
|
3637
|
+
*
|
3638
|
+
* @param row
|
3639
|
+
* @return
|
3640
|
+
*/
|
3641
|
+
public float[] getFloatRow(int row) {
|
3320
3642
|
float[] outgoing = new float[columns.length];
|
3321
3643
|
for (int col = 0; col < columns.length; col++) {
|
3322
3644
|
outgoing[col] = getFloat(row, col);
|
@@ -3327,6 +3649,13 @@ public class Table {
|
|
3327
3649
|
|
3328
3650
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
3329
3651
|
|
3652
|
+
/**
|
3653
|
+
*
|
3654
|
+
* @param row
|
3655
|
+
* @param column
|
3656
|
+
* @return
|
3657
|
+
*/
|
3658
|
+
|
3330
3659
|
|
3331
3660
|
public double getDouble(int row, int column) {
|
3332
3661
|
checkBounds(row, column);
|
@@ -3345,18 +3674,31 @@ public class Table {
|
|
3345
3674
|
}
|
3346
3675
|
}
|
3347
3676
|
|
3348
|
-
|
3349
|
-
|
3677
|
+
/**
|
3678
|
+
*
|
3679
|
+
* @param row
|
3680
|
+
* @param columnName
|
3681
|
+
* @return
|
3682
|
+
*/
|
3683
|
+
public double getDouble(int row, String columnName) {
|
3350
3684
|
return getDouble(row, getColumnIndex(columnName));
|
3351
3685
|
}
|
3352
3686
|
|
3353
|
-
|
3354
|
-
|
3687
|
+
/**
|
3688
|
+
*
|
3689
|
+
* @param value
|
3690
|
+
*/
|
3691
|
+
public void setMissingDouble(double value) {
|
3355
3692
|
missingDouble = value;
|
3356
3693
|
}
|
3357
3694
|
|
3358
|
-
|
3359
|
-
|
3695
|
+
/**
|
3696
|
+
*
|
3697
|
+
* @param row
|
3698
|
+
* @param column
|
3699
|
+
* @param value
|
3700
|
+
*/
|
3701
|
+
public void setDouble(int row, int column, double value) {
|
3360
3702
|
if (columnTypes[column] == STRING) {
|
3361
3703
|
setString(row, column, String.valueOf(value));
|
3362
3704
|
|
@@ -3370,19 +3712,32 @@ public class Table {
|
|
3370
3712
|
}
|
3371
3713
|
}
|
3372
3714
|
|
3373
|
-
|
3374
|
-
|
3715
|
+
/**
|
3716
|
+
*
|
3717
|
+
* @param row
|
3718
|
+
* @param columnName
|
3719
|
+
* @param value
|
3720
|
+
*/
|
3721
|
+
public void setDouble(int row, String columnName, double value) {
|
3375
3722
|
setDouble(row, getColumnIndex(columnName), value);
|
3376
3723
|
}
|
3377
3724
|
|
3378
|
-
|
3379
|
-
|
3725
|
+
/**
|
3726
|
+
*
|
3727
|
+
* @param name
|
3728
|
+
* @return
|
3729
|
+
*/
|
3730
|
+
public double[] getDoubleColumn(String name) {
|
3380
3731
|
int col = getColumnIndex(name);
|
3381
3732
|
return (col == -1) ? null : getDoubleColumn(col);
|
3382
3733
|
}
|
3383
3734
|
|
3384
|
-
|
3385
|
-
|
3735
|
+
/**
|
3736
|
+
*
|
3737
|
+
* @param col
|
3738
|
+
* @return
|
3739
|
+
*/
|
3740
|
+
public double[] getDoubleColumn(int col) {
|
3386
3741
|
double[] outgoing = new double[rowCount];
|
3387
3742
|
for (int row = 0; row < rowCount; row++) {
|
3388
3743
|
outgoing[row] = getDouble(row, col);
|
@@ -3390,8 +3745,12 @@ public class Table {
|
|
3390
3745
|
return outgoing;
|
3391
3746
|
}
|
3392
3747
|
|
3393
|
-
|
3394
|
-
|
3748
|
+
/**
|
3749
|
+
*
|
3750
|
+
* @param row
|
3751
|
+
* @return
|
3752
|
+
*/
|
3753
|
+
public double[] getDoubleRow(int row) {
|
3395
3754
|
double[] outgoing = new double[columns.length];
|
3396
3755
|
for (int col = 0; col < columns.length; col++) {
|
3397
3756
|
outgoing[col] = getDouble(row, col);
|
@@ -3460,8 +3819,9 @@ public class Table {
|
|
3460
3819
|
|
3461
3820
|
|
3462
3821
|
/**
|
3463
|
-
* Get a String value from the table.
|
3822
|
+
* Get a String value from the table.If the row is longer than the table
|
3464
3823
|
*
|
3824
|
+
* @return
|
3465
3825
|
* @webref table:method
|
3466
3826
|
* @brief Get an String value from the specified row and column
|
3467
3827
|
* @param row ID number of the row to reference
|
@@ -3498,7 +3858,9 @@ public class Table {
|
|
3498
3858
|
|
3499
3859
|
|
3500
3860
|
/**
|
3861
|
+
* @param row
|
3501
3862
|
* @param columnName title of the column to reference
|
3863
|
+
* @return
|
3502
3864
|
*/
|
3503
3865
|
public String getString(int row, String columnName) {
|
3504
3866
|
return getString(row, getColumnIndex(columnName));
|
@@ -3506,7 +3868,8 @@ public class Table {
|
|
3506
3868
|
|
3507
3869
|
|
3508
3870
|
/**
|
3509
|
-
* Treat entries with this string as "missing".
|
3871
|
+
* Treat entries with this string as "missing".Also used for categorial.
|
3872
|
+
* @param value
|
3510
3873
|
*/
|
3511
3874
|
public void setMissingString(String value) {
|
3512
3875
|
missingString = value;
|
@@ -3536,7 +3899,9 @@ public class Table {
|
|
3536
3899
|
}
|
3537
3900
|
|
3538
3901
|
/**
|
3902
|
+
* @param row
|
3539
3903
|
* @param columnName title of the target column
|
3904
|
+
* @param value
|
3540
3905
|
*/
|
3541
3906
|
public void setString(int row, String columnName, String value) {
|
3542
3907
|
int column = checkColumnIndex(columnName);
|
@@ -3544,6 +3909,7 @@ public class Table {
|
|
3544
3909
|
}
|
3545
3910
|
|
3546
3911
|
/**
|
3912
|
+
* @return
|
3547
3913
|
* @webref table:method
|
3548
3914
|
* @brief Gets all values in the specified column
|
3549
3915
|
* @param columnName title of the column to search
|
@@ -3562,6 +3928,7 @@ public class Table {
|
|
3562
3928
|
|
3563
3929
|
/**
|
3564
3930
|
* @param column ID number of the column to search
|
3931
|
+
* @return
|
3565
3932
|
*/
|
3566
3933
|
public String[] getStringColumn(int column) {
|
3567
3934
|
String[] outgoing = new String[rowCount];
|
@@ -3571,8 +3938,12 @@ public class Table {
|
|
3571
3938
|
return outgoing;
|
3572
3939
|
}
|
3573
3940
|
|
3574
|
-
|
3575
|
-
|
3941
|
+
/**
|
3942
|
+
*
|
3943
|
+
* @param row
|
3944
|
+
* @return
|
3945
|
+
*/
|
3946
|
+
public String[] getStringRow(int row) {
|
3576
3947
|
String[] outgoing = new String[columns.length];
|
3577
3948
|
for (int col = 0; col < columns.length; col++) {
|
3578
3949
|
outgoing[col] = getString(row, col);
|
@@ -3588,6 +3959,7 @@ public class Table {
|
|
3588
3959
|
* Return the row that contains the first String that matches.
|
3589
3960
|
* @param value the String to match
|
3590
3961
|
* @param column ID number of the column to search
|
3962
|
+
* @return
|
3591
3963
|
*/
|
3592
3964
|
public int findRowIndex(String value, int column) {
|
3593
3965
|
checkColumn(column);
|
@@ -3624,6 +3996,7 @@ public class Table {
|
|
3624
3996
|
* Return the row that contains the first String that matches.
|
3625
3997
|
* @param value the String to match
|
3626
3998
|
* @param columnName title of the column to search
|
3999
|
+
* @return
|
3627
4000
|
*/
|
3628
4001
|
public int findRowIndex(String value, String columnName) {
|
3629
4002
|
return findRowIndex(value, getColumnIndex(columnName));
|
@@ -3631,10 +4004,11 @@ public class Table {
|
|
3631
4004
|
|
3632
4005
|
|
3633
4006
|
/**
|
3634
|
-
* Return a list of rows that contain the String passed in.
|
3635
|
-
|
4007
|
+
* Return a list of rows that contain the String passed in.If there are no
|
4008
|
+
matches, a zero length array will be returned (not a null array).
|
3636
4009
|
* @param value the String to match
|
3637
4010
|
* @param column ID number of the column to search
|
4011
|
+
* @return
|
3638
4012
|
*/
|
3639
4013
|
public int[] findRowIndices(String value, int column) {
|
3640
4014
|
int[] outgoing = new int[rowCount];
|
@@ -3673,10 +4047,11 @@ public class Table {
|
|
3673
4047
|
|
3674
4048
|
|
3675
4049
|
/**
|
3676
|
-
* Return a list of rows that contain the String passed in.
|
3677
|
-
|
4050
|
+
* Return a list of rows that contain the String passed in.If there are no
|
4051
|
+
matches, a zero length array will be returned (not a null array).
|
3678
4052
|
* @param value the String to match
|
3679
4053
|
* @param columnName title of the column to search
|
4054
|
+
* @return
|
3680
4055
|
*/
|
3681
4056
|
public int[] findRowIndices(String value, String columnName) {
|
3682
4057
|
return findRowIndices(value, getColumnIndex(columnName));
|
@@ -3686,6 +4061,7 @@ public class Table {
|
|
3686
4061
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
3687
4062
|
|
3688
4063
|
/**
|
4064
|
+
* @return
|
3689
4065
|
* @webref table:method
|
3690
4066
|
* @brief Finds a row that contains the given value
|
3691
4067
|
* @param value the value to match
|
@@ -3703,7 +4079,9 @@ public class Table {
|
|
3703
4079
|
|
3704
4080
|
|
3705
4081
|
/**
|
4082
|
+
* @param value
|
3706
4083
|
* @param columnName title of the column to search
|
4084
|
+
* @return
|
3707
4085
|
*/
|
3708
4086
|
public TableRow findRow(String value, String columnName) {
|
3709
4087
|
return findRow(value, getColumnIndex(columnName));
|
@@ -3711,6 +4089,7 @@ public class Table {
|
|
3711
4089
|
|
3712
4090
|
|
3713
4091
|
/**
|
4092
|
+
* @return
|
3714
4093
|
* @webref table:method
|
3715
4094
|
* @brief Finds multiple rows that contain the given value
|
3716
4095
|
* @param value the value to match
|
@@ -3731,7 +4110,9 @@ public class Table {
|
|
3731
4110
|
|
3732
4111
|
|
3733
4112
|
/**
|
4113
|
+
* @param value
|
3734
4114
|
* @param columnName title of the column to search
|
4115
|
+
* @return
|
3735
4116
|
*/
|
3736
4117
|
public Iterable<TableRow> findRows(final String value, final String columnName) {
|
3737
4118
|
return findRows(value, getColumnIndex(columnName));
|
@@ -3739,6 +4120,7 @@ public class Table {
|
|
3739
4120
|
|
3740
4121
|
|
3741
4122
|
/**
|
4123
|
+
* @return
|
3742
4124
|
* @brief Finds multiple rows that contain the given value
|
3743
4125
|
* @param value the value to match
|
3744
4126
|
* @param column ID number of the column to search
|
@@ -3749,7 +4131,9 @@ public class Table {
|
|
3749
4131
|
|
3750
4132
|
|
3751
4133
|
/**
|
4134
|
+
* @param value
|
3752
4135
|
* @param columnName title of the column to search
|
4136
|
+
* @return
|
3753
4137
|
*/
|
3754
4138
|
public Iterator<TableRow> findRowIterator(String value, String columnName) {
|
3755
4139
|
return findRowIterator(value, getColumnIndex(columnName));
|
@@ -3763,6 +4147,7 @@ public class Table {
|
|
3763
4147
|
* Return the row that contains the first String that matches.
|
3764
4148
|
* @param regexp the String to match
|
3765
4149
|
* @param column ID number of the column to search
|
4150
|
+
* @return
|
3766
4151
|
*/
|
3767
4152
|
public int matchRowIndex(String regexp, int column) {
|
3768
4153
|
checkColumn(column);
|
@@ -3791,6 +4176,7 @@ public class Table {
|
|
3791
4176
|
* Return the row that contains the first String that matches.
|
3792
4177
|
* @param what the String to match
|
3793
4178
|
* @param columnName title of the column to search
|
4179
|
+
* @return
|
3794
4180
|
*/
|
3795
4181
|
public int matchRowIndex(String what, String columnName) {
|
3796
4182
|
return matchRowIndex(what, getColumnIndex(columnName));
|
@@ -3798,10 +4184,11 @@ public class Table {
|
|
3798
4184
|
|
3799
4185
|
|
3800
4186
|
/**
|
3801
|
-
* Return a list of rows that contain the String passed in.
|
3802
|
-
|
4187
|
+
* Return a list of rows that contain the String passed in.If there are no
|
4188
|
+
matches, a zero length array will be returned (not a null array).
|
3803
4189
|
* @param regexp the String to match
|
3804
4190
|
* @param column ID number of the column to search
|
4191
|
+
* @return
|
3805
4192
|
*/
|
3806
4193
|
public int[] matchRowIndices(String regexp, int column) {
|
3807
4194
|
int[] outgoing = new int[rowCount];
|
@@ -3830,10 +4217,11 @@ public class Table {
|
|
3830
4217
|
|
3831
4218
|
|
3832
4219
|
/**
|
3833
|
-
* Return a list of rows that match the regex passed in.
|
3834
|
-
|
4220
|
+
* Return a list of rows that match the regex passed in.If there are no
|
4221
|
+
matches, a zero length array will be returned (not a null array).
|
3835
4222
|
* @param what the String to match
|
3836
4223
|
* @param columnName title of the column to search
|
4224
|
+
* @return
|
3837
4225
|
*/
|
3838
4226
|
public int[] matchRowIndices(String what, String columnName) {
|
3839
4227
|
return matchRowIndices(what, getColumnIndex(columnName));
|
@@ -3843,6 +4231,7 @@ public class Table {
|
|
3843
4231
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
3844
4232
|
|
3845
4233
|
/**
|
4234
|
+
* @return
|
3846
4235
|
* @webref table:method
|
3847
4236
|
* @brief Finds a row that matches the given expression
|
3848
4237
|
* @param regexp the regular expression to match
|
@@ -3860,7 +4249,9 @@ public class Table {
|
|
3860
4249
|
|
3861
4250
|
|
3862
4251
|
/**
|
4252
|
+
* @param regexp
|
3863
4253
|
* @param columnName title of the column to search
|
4254
|
+
* @return
|
3864
4255
|
*/
|
3865
4256
|
public TableRow matchRow(String regexp, String columnName) {
|
3866
4257
|
return matchRow(regexp, getColumnIndex(columnName));
|
@@ -3868,6 +4259,7 @@ public class Table {
|
|
3868
4259
|
|
3869
4260
|
|
3870
4261
|
/**
|
4262
|
+
* @return
|
3871
4263
|
* @webref table:method
|
3872
4264
|
* @brief Finds multiple rows that match the given expression
|
3873
4265
|
* @param regexp the regular expression to match
|
@@ -3888,7 +4280,9 @@ public class Table {
|
|
3888
4280
|
|
3889
4281
|
|
3890
4282
|
/**
|
4283
|
+
* @param regexp
|
3891
4284
|
* @param columnName title of the column to search
|
4285
|
+
* @return
|
3892
4286
|
*/
|
3893
4287
|
public Iterable<TableRow> matchRows(String regexp, String columnName) {
|
3894
4288
|
return matchRows(regexp, getColumnIndex(columnName));
|
@@ -3896,6 +4290,7 @@ public class Table {
|
|
3896
4290
|
|
3897
4291
|
|
3898
4292
|
/**
|
4293
|
+
* @return
|
3899
4294
|
* @webref table:method
|
3900
4295
|
* @brief Finds multiple rows that match the given expression
|
3901
4296
|
* @param value the regular expression to match
|
@@ -3907,7 +4302,9 @@ public class Table {
|
|
3907
4302
|
|
3908
4303
|
|
3909
4304
|
/**
|
4305
|
+
* @param value
|
3910
4306
|
* @param columnName title of the column to search
|
4307
|
+
* @return
|
3911
4308
|
*/
|
3912
4309
|
public Iterator<TableRow> matchRowIterator(String value, String columnName) {
|
3913
4310
|
return matchRowIterator(value, getColumnIndex(columnName));
|
@@ -3930,8 +4327,13 @@ public class Table {
|
|
3930
4327
|
}
|
3931
4328
|
}
|
3932
4329
|
|
3933
|
-
|
3934
|
-
|
4330
|
+
/**
|
4331
|
+
*
|
4332
|
+
* @param orig
|
4333
|
+
* @param replacement
|
4334
|
+
* @param col
|
4335
|
+
*/
|
4336
|
+
public void replace(String orig, String replacement, int col) {
|
3935
4337
|
if (columnTypes[col] == STRING) {
|
3936
4338
|
String[] stringData = (String[]) columns[col];
|
3937
4339
|
|
@@ -3951,14 +4353,25 @@ public class Table {
|
|
3951
4353
|
}
|
3952
4354
|
}
|
3953
4355
|
|
3954
|
-
|
3955
|
-
|
4356
|
+
/**
|
4357
|
+
*
|
4358
|
+
* @param orig
|
4359
|
+
* @param replacement
|
4360
|
+
* @param colName
|
4361
|
+
*/
|
4362
|
+
public void replace(String orig, String replacement, String colName) {
|
3956
4363
|
replace(orig, replacement, getColumnIndex(colName));
|
3957
4364
|
}
|
3958
4365
|
|
3959
4366
|
|
3960
4367
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
3961
4368
|
|
4369
|
+
/**
|
4370
|
+
*
|
4371
|
+
* @param regex
|
4372
|
+
* @param replacement
|
4373
|
+
*/
|
4374
|
+
|
3962
4375
|
|
3963
4376
|
public void replaceAll(String regex, String replacement) {
|
3964
4377
|
for (int col = 0; col < columns.length; col++) {
|
@@ -3966,8 +4379,13 @@ public class Table {
|
|
3966
4379
|
}
|
3967
4380
|
}
|
3968
4381
|
|
3969
|
-
|
3970
|
-
|
4382
|
+
/**
|
4383
|
+
*
|
4384
|
+
* @param regex
|
4385
|
+
* @param replacement
|
4386
|
+
* @param column
|
4387
|
+
*/
|
4388
|
+
public void replaceAll(String regex, String replacement, int column) {
|
3971
4389
|
checkColumn(column);
|
3972
4390
|
if (columnTypes[column] == STRING) {
|
3973
4391
|
String[] stringData = (String[]) columns[column];
|
@@ -3983,9 +4401,9 @@ public class Table {
|
|
3983
4401
|
|
3984
4402
|
|
3985
4403
|
/**
|
3986
|
-
* Run String.replaceAll() on all entries in a column.
|
3987
|
-
* Only works with columns that are already String values.
|
4404
|
+
* Run String.replaceAll() on all entries in a column.Only works with columns that are already String values.
|
3988
4405
|
* @param regex the String to match
|
4406
|
+
* @param replacement
|
3989
4407
|
* @param columnName title of the column to search
|
3990
4408
|
*/
|
3991
4409
|
public void replaceAll(String regex, String replacement, String columnName) {
|
@@ -4012,12 +4430,12 @@ public class Table {
|
|
4012
4430
|
|
4013
4431
|
|
4014
4432
|
/**
|
4015
|
-
* Removed any of the specified characters from a column.
|
4016
|
-
|
4017
|
-
* <pre>
|
4433
|
+
* Removed any of the specified characters from a column.For instance,
|
4434
|
+
the following code removes dollar signs and commas from column 2:<pre>
|
4018
4435
|
* table.removeTokens(",$", 2);
|
4019
4436
|
* </pre>
|
4020
4437
|
*
|
4438
|
+
* @param tokens
|
4021
4439
|
* @param column ID number of the column to process
|
4022
4440
|
*/
|
4023
4441
|
public void removeTokens(String tokens, int column) {
|
@@ -4042,6 +4460,7 @@ public class Table {
|
|
4042
4460
|
}
|
4043
4461
|
|
4044
4462
|
/**
|
4463
|
+
* @param tokens
|
4045
4464
|
* @param columnName title of the column to process
|
4046
4465
|
*/
|
4047
4466
|
public void removeTokens(String tokens, String columnName) {
|
@@ -4088,8 +4507,12 @@ public class Table {
|
|
4088
4507
|
}
|
4089
4508
|
}
|
4090
4509
|
|
4091
|
-
|
4092
|
-
|
4510
|
+
/**
|
4511
|
+
*
|
4512
|
+
* @param contents
|
4513
|
+
* @return
|
4514
|
+
*/
|
4515
|
+
protected boolean isEmptyArray(String[] contents) {
|
4093
4516
|
for (String entry : contents) {
|
4094
4517
|
if (entry != null && entry.length() > 0) {
|
4095
4518
|
return false;
|
@@ -4148,7 +4571,8 @@ public class Table {
|
|
4148
4571
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
4149
4572
|
|
4150
4573
|
|
4151
|
-
/** Make sure this is a legit column, and if not, expand the table.
|
4574
|
+
/** Make sure this is a legit column, and if not, expand the table.
|
4575
|
+
* @param col */
|
4152
4576
|
protected void ensureColumn(int col) {
|
4153
4577
|
if (col >= columns.length) {
|
4154
4578
|
setColumnCount(col + 1);
|
@@ -4156,7 +4580,8 @@ public class Table {
|
|
4156
4580
|
}
|
4157
4581
|
|
4158
4582
|
|
4159
|
-
/** Make sure this is a legit row, and if not, expand the table.
|
4583
|
+
/** Make sure this is a legit row, and if not, expand the table.
|
4584
|
+
* @param row */
|
4160
4585
|
protected void ensureRow(int row) {
|
4161
4586
|
if (row >= rowCount) {
|
4162
4587
|
setRowCount(row + 1);
|
@@ -4164,14 +4589,17 @@ public class Table {
|
|
4164
4589
|
}
|
4165
4590
|
|
4166
4591
|
|
4167
|
-
/** Make sure this is a legit row and column.
|
4592
|
+
/** * Make sure this is a legit row and column.If not, expand the table.
|
4593
|
+
* @param row
|
4594
|
+
* @param col */
|
4168
4595
|
protected void ensureBounds(int row, int col) {
|
4169
4596
|
ensureRow(row);
|
4170
4597
|
ensureColumn(col);
|
4171
4598
|
}
|
4172
4599
|
|
4173
4600
|
|
4174
|
-
/** Throw an error if this row doesn't exist.
|
4601
|
+
/** Throw an error if this row doesn't exist.
|
4602
|
+
* @param row */
|
4175
4603
|
protected void checkRow(int row) {
|
4176
4604
|
if (row < 0 || row >= rowCount) {
|
4177
4605
|
throw new ArrayIndexOutOfBoundsException("Row " + row + " does not exist.");
|
@@ -4179,7 +4607,8 @@ public class Table {
|
|
4179
4607
|
}
|
4180
4608
|
|
4181
4609
|
|
4182
|
-
/** Throw an error if this column doesn't exist.
|
4610
|
+
/** Throw an error if this column doesn't exist.
|
4611
|
+
* @param column */
|
4183
4612
|
protected void checkColumn(int column) {
|
4184
4613
|
if (column < 0 || column >= columns.length) {
|
4185
4614
|
throw new ArrayIndexOutOfBoundsException("Column " + column + " does not exist.");
|
@@ -4187,7 +4616,9 @@ public class Table {
|
|
4187
4616
|
}
|
4188
4617
|
|
4189
4618
|
|
4190
|
-
/** Throw an error if this entry is out of bounds.
|
4619
|
+
/** Throw an error if this entry is out of bounds.
|
4620
|
+
* @param row
|
4621
|
+
* @param column */
|
4191
4622
|
protected void checkBounds(int row, int column) {
|
4192
4623
|
checkRow(row);
|
4193
4624
|
checkColumn(column);
|
@@ -4312,18 +4743,28 @@ public class Table {
|
|
4312
4743
|
sort(column, false);
|
4313
4744
|
}
|
4314
4745
|
|
4315
|
-
|
4316
|
-
|
4746
|
+
/**
|
4747
|
+
*
|
4748
|
+
* @param columnName
|
4749
|
+
*/
|
4750
|
+
public void sortReverse(String columnName) {
|
4317
4751
|
sort(getColumnIndex(columnName), true);
|
4318
4752
|
}
|
4319
4753
|
|
4320
|
-
|
4321
|
-
|
4754
|
+
/**
|
4755
|
+
*
|
4756
|
+
* @param column
|
4757
|
+
*/
|
4758
|
+
public void sortReverse(int column) {
|
4322
4759
|
sort(column, true);
|
4323
4760
|
}
|
4324
4761
|
|
4325
|
-
|
4326
|
-
|
4762
|
+
/**
|
4763
|
+
*
|
4764
|
+
* @param column
|
4765
|
+
* @param reverse
|
4766
|
+
*/
|
4767
|
+
protected void sort(final int column, final boolean reverse) {
|
4327
4768
|
final int[] order = IntList.fromRange(getRowCount()).array();
|
4328
4769
|
Sort s = new Sort() {
|
4329
4770
|
|
@@ -4416,35 +4857,61 @@ public class Table {
|
|
4416
4857
|
|
4417
4858
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
4418
4859
|
|
4860
|
+
/**
|
4861
|
+
*
|
4862
|
+
* @param columnName
|
4863
|
+
* @return
|
4864
|
+
*/
|
4865
|
+
|
4419
4866
|
|
4420
4867
|
public String[] getUnique(String columnName) {
|
4421
4868
|
return getUnique(getColumnIndex(columnName));
|
4422
4869
|
}
|
4423
4870
|
|
4424
|
-
|
4425
|
-
|
4871
|
+
/**
|
4872
|
+
*
|
4873
|
+
* @param column
|
4874
|
+
* @return
|
4875
|
+
*/
|
4876
|
+
public String[] getUnique(int column) {
|
4426
4877
|
StringList list = new StringList(getStringColumn(column));
|
4427
4878
|
return list.getUnique();
|
4428
4879
|
}
|
4429
4880
|
|
4430
|
-
|
4431
|
-
|
4881
|
+
/**
|
4882
|
+
*
|
4883
|
+
* @param columnName
|
4884
|
+
* @return
|
4885
|
+
*/
|
4886
|
+
public IntDict getTally(String columnName) {
|
4432
4887
|
return getTally(getColumnIndex(columnName));
|
4433
4888
|
}
|
4434
4889
|
|
4435
|
-
|
4436
|
-
|
4890
|
+
/**
|
4891
|
+
*
|
4892
|
+
* @param column
|
4893
|
+
* @return
|
4894
|
+
*/
|
4895
|
+
public IntDict getTally(int column) {
|
4437
4896
|
StringList list = new StringList(getStringColumn(column));
|
4438
4897
|
return list.getTally();
|
4439
4898
|
}
|
4440
4899
|
|
4441
|
-
|
4442
|
-
|
4900
|
+
/**
|
4901
|
+
*
|
4902
|
+
* @param columnName
|
4903
|
+
* @return
|
4904
|
+
*/
|
4905
|
+
public IntDict getOrder(String columnName) {
|
4443
4906
|
return getOrder(getColumnIndex(columnName));
|
4444
4907
|
}
|
4445
4908
|
|
4446
|
-
|
4447
|
-
|
4909
|
+
/**
|
4910
|
+
*
|
4911
|
+
* @param column
|
4912
|
+
* @return
|
4913
|
+
*/
|
4914
|
+
public IntDict getOrder(int column) {
|
4448
4915
|
StringList list = new StringList(getStringColumn(column));
|
4449
4916
|
return list.getOrder();
|
4450
4917
|
}
|
@@ -4452,77 +4919,139 @@ public class Table {
|
|
4452
4919
|
|
4453
4920
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
4454
4921
|
|
4922
|
+
/**
|
4923
|
+
*
|
4924
|
+
* @param columnName
|
4925
|
+
* @return
|
4926
|
+
*/
|
4927
|
+
|
4455
4928
|
|
4456
4929
|
public IntList getIntList(String columnName) {
|
4457
4930
|
return new IntList(getIntColumn(columnName));
|
4458
4931
|
}
|
4459
4932
|
|
4460
|
-
|
4461
|
-
|
4933
|
+
/**
|
4934
|
+
*
|
4935
|
+
* @param column
|
4936
|
+
* @return
|
4937
|
+
*/
|
4938
|
+
public IntList getIntList(int column) {
|
4462
4939
|
return new IntList(getIntColumn(column));
|
4463
4940
|
}
|
4464
4941
|
|
4465
|
-
|
4466
|
-
|
4942
|
+
/**
|
4943
|
+
*
|
4944
|
+
* @param columnName
|
4945
|
+
* @return
|
4946
|
+
*/
|
4947
|
+
public FloatList getFloatList(String columnName) {
|
4467
4948
|
return new FloatList(getFloatColumn(columnName));
|
4468
4949
|
}
|
4469
4950
|
|
4470
|
-
|
4471
|
-
|
4951
|
+
/**
|
4952
|
+
*
|
4953
|
+
* @param column
|
4954
|
+
* @return
|
4955
|
+
*/
|
4956
|
+
public FloatList getFloatList(int column) {
|
4472
4957
|
return new FloatList(getFloatColumn(column));
|
4473
4958
|
}
|
4474
4959
|
|
4475
|
-
|
4476
|
-
|
4960
|
+
/**
|
4961
|
+
*
|
4962
|
+
* @param columnName
|
4963
|
+
* @return
|
4964
|
+
*/
|
4965
|
+
public StringList getStringList(String columnName) {
|
4477
4966
|
return new StringList(getStringColumn(columnName));
|
4478
4967
|
}
|
4479
4968
|
|
4480
|
-
|
4481
|
-
|
4969
|
+
/**
|
4970
|
+
*
|
4971
|
+
* @param column
|
4972
|
+
* @return
|
4973
|
+
*/
|
4974
|
+
public StringList getStringList(int column) {
|
4482
4975
|
return new StringList(getStringColumn(column));
|
4483
4976
|
}
|
4484
4977
|
|
4485
4978
|
|
4486
4979
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
4487
4980
|
|
4981
|
+
/**
|
4982
|
+
*
|
4983
|
+
* @param keyColumnName
|
4984
|
+
* @param valueColumnName
|
4985
|
+
* @return
|
4986
|
+
*/
|
4987
|
+
|
4488
4988
|
|
4489
4989
|
public IntDict getIntDict(String keyColumnName, String valueColumnName) {
|
4490
4990
|
return new IntDict(getStringColumn(keyColumnName),
|
4491
4991
|
getIntColumn(valueColumnName));
|
4492
4992
|
}
|
4493
4993
|
|
4494
|
-
|
4495
|
-
|
4994
|
+
/**
|
4995
|
+
*
|
4996
|
+
* @param keyColumn
|
4997
|
+
* @param valueColumn
|
4998
|
+
* @return
|
4999
|
+
*/
|
5000
|
+
public IntDict getIntDict(int keyColumn, int valueColumn) {
|
4496
5001
|
return new IntDict(getStringColumn(keyColumn),
|
4497
5002
|
getIntColumn(valueColumn));
|
4498
5003
|
}
|
4499
5004
|
|
4500
|
-
|
4501
|
-
|
5005
|
+
/**
|
5006
|
+
*
|
5007
|
+
* @param keyColumnName
|
5008
|
+
* @param valueColumnName
|
5009
|
+
* @return
|
5010
|
+
*/
|
5011
|
+
public FloatDict getFloatDict(String keyColumnName, String valueColumnName) {
|
4502
5012
|
return new FloatDict(getStringColumn(keyColumnName),
|
4503
5013
|
getFloatColumn(valueColumnName));
|
4504
5014
|
}
|
4505
5015
|
|
4506
|
-
|
4507
|
-
|
5016
|
+
/**
|
5017
|
+
*
|
5018
|
+
* @param keyColumn
|
5019
|
+
* @param valueColumn
|
5020
|
+
* @return
|
5021
|
+
*/
|
5022
|
+
public FloatDict getFloatDict(int keyColumn, int valueColumn) {
|
4508
5023
|
return new FloatDict(getStringColumn(keyColumn),
|
4509
5024
|
getFloatColumn(valueColumn));
|
4510
5025
|
}
|
4511
5026
|
|
4512
|
-
|
4513
|
-
|
5027
|
+
/**
|
5028
|
+
*
|
5029
|
+
* @param keyColumnName
|
5030
|
+
* @param valueColumnName
|
5031
|
+
* @return
|
5032
|
+
*/
|
5033
|
+
public StringDict getStringDict(String keyColumnName, String valueColumnName) {
|
4514
5034
|
return new StringDict(getStringColumn(keyColumnName),
|
4515
5035
|
getStringColumn(valueColumnName));
|
4516
5036
|
}
|
4517
5037
|
|
4518
|
-
|
4519
|
-
|
5038
|
+
/**
|
5039
|
+
*
|
5040
|
+
* @param keyColumn
|
5041
|
+
* @param valueColumn
|
5042
|
+
* @return
|
5043
|
+
*/
|
5044
|
+
public StringDict getStringDict(int keyColumn, int valueColumn) {
|
4520
5045
|
return new StringDict(getStringColumn(keyColumn),
|
4521
5046
|
getStringColumn(valueColumn));
|
4522
5047
|
}
|
4523
5048
|
|
4524
|
-
|
4525
|
-
|
5049
|
+
/**
|
5050
|
+
*
|
5051
|
+
* @param columnName
|
5052
|
+
* @return
|
5053
|
+
*/
|
5054
|
+
public Map<String, TableRow> getRowMap(String columnName) {
|
4526
5055
|
int col = getColumnIndex(columnName);
|
4527
5056
|
return (col == -1) ? null : getRowMap(col);
|
4528
5057
|
}
|
@@ -4530,8 +5059,7 @@ public class Table {
|
|
4530
5059
|
|
4531
5060
|
/**
|
4532
5061
|
* Return a mapping that connects the entry from a column back to the row
|
4533
|
-
* from which it came.
|
4534
|
-
* <pre>
|
5062
|
+
* from which it came.For instance:<pre>
|
4535
5063
|
* Table t = loadTable("country-data.tsv", "header");
|
4536
5064
|
* // use the contents of the 'country' column to index the table
|
4537
5065
|
* Map<String, TableRow> lookup = t.getRowMap("country");
|
@@ -4540,6 +5068,8 @@ public class Table {
|
|
4540
5068
|
* // get an entry from the 'population' column
|
4541
5069
|
* int population = usRow.getInt("population");
|
4542
5070
|
* </pre>
|
5071
|
+
* @param column
|
5072
|
+
* @return
|
4543
5073
|
*/
|
4544
5074
|
public Map<String, TableRow> getRowMap(int column) {
|
4545
5075
|
Map<String, TableRow> outgoing = new HashMap<>();
|
@@ -4674,6 +5204,12 @@ public class Table {
|
|
4674
5204
|
|
4675
5205
|
|
4676
5206
|
// TODO naming/whether to include
|
5207
|
+
|
5208
|
+
/**
|
5209
|
+
*
|
5210
|
+
* @param rowSubset
|
5211
|
+
* @return
|
5212
|
+
*/
|
4677
5213
|
protected Table createSubset(int[] rowSubset) {
|
4678
5214
|
Table newbie = new Table();
|
4679
5215
|
newbie.setColumnTitles(columnTitles); // also sets columns.length
|
@@ -4700,8 +5236,8 @@ public class Table {
|
|
4700
5236
|
|
4701
5237
|
|
4702
5238
|
/**
|
4703
|
-
* Searches the entire table for float values.
|
4704
|
-
|
5239
|
+
* Searches the entire table for float values.Returns missing float (Float.NaN by default) if no valid numbers found.
|
5240
|
+
* @return
|
4705
5241
|
*/
|
4706
5242
|
protected float getMaxFloat() {
|
4707
5243
|
boolean found = false;
|
@@ -4727,6 +5263,14 @@ public class Table {
|
|
4727
5263
|
|
4728
5264
|
|
4729
5265
|
// converts a TSV or CSV file to binary.. do not use
|
5266
|
+
|
5267
|
+
/**
|
5268
|
+
*
|
5269
|
+
* @param reader
|
5270
|
+
* @param tsv
|
5271
|
+
* @param outputFile
|
5272
|
+
* @throws IOException
|
5273
|
+
*/
|
4730
5274
|
protected void convertBasic(BufferedReader reader, boolean tsv,
|
4731
5275
|
File outputFile) throws IOException {
|
4732
5276
|
FileOutputStream fos = new FileOutputStream(outputFile);
|
@@ -4800,8 +5344,13 @@ public class Table {
|
|
4800
5344
|
raf.close();
|
4801
5345
|
}
|
4802
5346
|
|
4803
|
-
|
4804
|
-
|
5347
|
+
/**
|
5348
|
+
*
|
5349
|
+
* @param output
|
5350
|
+
* @param pieces
|
5351
|
+
* @throws IOException
|
5352
|
+
*/
|
5353
|
+
protected void convertRow(DataOutputStream output, String[] pieces) throws IOException {
|
4805
5354
|
if (pieces.length > getColumnCount()) {
|
4806
5355
|
throw new IllegalArgumentException("Row with too many columns: " +
|
4807
5356
|
PApplet.join(pieces, ","));
|
@@ -4906,18 +5455,24 @@ public class Table {
|
|
4906
5455
|
*/
|
4907
5456
|
|
4908
5457
|
|
4909
|
-
/** Make a copy of the current table
|
5458
|
+
/** Make a copy of the current table
|
5459
|
+
* @return */
|
4910
5460
|
public Table copy() {
|
4911
5461
|
return new Table(rows());
|
4912
5462
|
}
|
4913
5463
|
|
4914
|
-
|
4915
|
-
|
5464
|
+
/**
|
5465
|
+
*
|
5466
|
+
* @param writer
|
5467
|
+
*/
|
5468
|
+
public void write(PrintWriter writer) {
|
4916
5469
|
writeTSV(writer);
|
4917
5470
|
}
|
4918
5471
|
|
4919
|
-
|
4920
|
-
|
5472
|
+
/**
|
5473
|
+
*
|
5474
|
+
*/
|
5475
|
+
public void print() {
|
4921
5476
|
writeTSV(new PrintWriter(System.out));
|
4922
5477
|
}
|
4923
5478
|
}
|