File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -214,6 +214,17 @@ public boolean isSet(final String name) {
214214 return isMapped (name ) && getHeaderMapRaw ().get (name ).intValue () < values .length ;
215215 }
216216
217+ /**
218+ * Checks whether a column with given index has a value.
219+ *
220+ * @param i
221+ * a column index (0-based)
222+ * @return whether a column with given index has a value
223+ */
224+ public boolean isSet (final int i ) {
225+ return 0 <= i && i < values .length ;
226+ }
227+
217228 /**
218229 * Returns an iterator over the values of this record.
219230 *
Original file line number Diff line number Diff line change @@ -134,12 +134,22 @@ public void testIsMapped() {
134134 }
135135
136136 @ Test
137- public void testIsSet () {
137+ public void testIsSetString () {
138138 assertFalse (record .isSet ("first" ));
139139 assertTrue (recordWithHeader .isSet ("first" ));
140140 assertFalse (recordWithHeader .isSet ("fourth" ));
141141 }
142142
143+ @ Test
144+ public void testIsSetInt () {
145+ assertFalse (record .isSet (-1 ));
146+ assertTrue (record .isSet (0 ));
147+ assertTrue (record .isSet (2 ));
148+ assertFalse (record .isSet (3 ));
149+ assertTrue (recordWithHeader .isSet (1 ));
150+ assertFalse (recordWithHeader .isSet (1000 ));
151+ }
152+
143153 @ Test
144154 public void testIterator () {
145155 int i = 0 ;
You can’t perform that action at this time.
0 commit comments