SelectResultSet extends AbstractResultSet { @Override public int findColumn(String columnLabel) { ensureOpen(); final Variable<OWLObject> v = namesToVariables.get(columnLabel); if (v == null) { return -1; } for (Map.Entry<Integer, Variable<OWLObject>> e : indexesToVariables.entrySet()) { if (e.getValue().equals(v)) { return e.getKey(); } } return -1; } SelectResultSet(QueryResult<OWLObject> queryResult, Statement statement); @Override int findColumn(String columnLabel); @Override int getColumnCount(); @Override boolean isBound(int variableIndex); @Override boolean isBound(String variableName); @Override void first(); @Override boolean getBoolean(int columnIndex); @Override boolean getBoolean(String columnLabel); @Override byte getByte(int columnIndex); @Override byte getByte(String columnLabel); @Override double getDouble(int columnIndex); @Override double getDouble(String columnLabel); @Override float getFloat(int columnIndex); @Override float getFloat(String columnLabel); @Override int getInt(int columnIndex); @Override int getInt(String columnLabel); @Override long getLong(int columnIndex); @Override long getLong(String columnLabel); @Override Object getObject(int columnIndex); @Override Object getObject(String columnLabel); @Override T getObject(int columnIndex, Class<T> cls); @Override T getObject(String columnLabel, Class<T> cls); @Override int getRowIndex(); @Override short getShort(int columnIndex); @Override short getShort(String columnLabel); @Override String getString(int columnIndex); @Override String getString(String columnLabel); @Override boolean isFirst(); @Override boolean hasNext(); @Override void last(); @Override void next(); @Override void previous(); @Override void relative(int rows); @Override void setRowIndex(int rowIndex);  }
@Test public void resultSetContainsCorrectMappingOfIndexesAndLabels() { final SelectResultSet resultSet = resultSet(generator.generate(Arrays.asList("a", "b"), Collections.singletonList( Arrays.asList(false, true)))); assertEquals(0, resultSet.findColumn("a")); assertEquals(1, resultSet.findColumn("b")); }
@Test public void findUnknownColumnIndexReturnsMinusOne() { SelectResultSet resultSet = resultSet( generator.generate(Arrays.asList("a", "b"), Collections.singletonList( Arrays.asList(false, true)))); assertEquals(-1, resultSet.findColumn("unknown")); }