public boolean include(Row row) { if (column == null) { return true; } Cell cell = row.getValues().get(column); return cell.getText().equals(pattern); } }
@Override public String toString(){ return getId(); } }
private Row readRow(){ Map<Column, Cell> values = new LinkedHashMap<Column, Cell>(); try { values.putAll(readMolfile()); values.putAll(readData()); } catch(EOFException eofe){ return null; } catch(IOException ioe){ throw new RuntimeException(ioe); } return new Row(String.valueOf(this.index++), values); }
private void loadParameters(Collection<? extends Parameter> params) { for (Parameter<?, ?> p: params) { Column column = new Column(p.getId()); columns.add(column); Map<String, String> values = loadValues(p); for (Row row: rows) { String v = values.get(row.getId()); row.getValues().put(column, makeCell(v)); } } }
public Row getRow(int row){ Map<Column, Cell> values = new LinkedHashMap<Column, Cell>(); int columns = getColumnCount(); for(int column = 0; column < columns; column++){ values.put(getColumn(column), getCell(row, column)); } return new Row(formatRowId(row), values); }
rows.add(new Row(rowIds[i], cells));
static public List<List<String>> formatCells(Table table) throws Exception { List<List<String>> result = new ArrayList<List<String>>(); List<Column> columns = new ArrayList<Column>(); for(Iterator<Column> it = table.columns(); it.hasNext(); ){ Column column = it.next(); columns.add(column); } for(Iterator<Row> it = table.rows(); it.hasNext(); ){ Row row = it.next(); Map<Column, Cell> values = row.getValues(); List<String> data = new ArrayList<String>(); for(Column column : columns){ Cell cell = values.get(column); data.add(format(cell != null ? cell.getText() : null)); } result.add(data); } return result; }
private void addCompounds(Collection<Compound> compounds) { for (Compound c: compounds) { Map<Column, Cell> values = new LinkedHashMap<Column, Cell>(); addAttribute(c.getId(), ID_COLUMN, values); addAttribute(c.getName(), NAME_COLUMN, values); addAttribute(c.getCas(), CAS_COLUMN, values); addAttribute(c.getInChI(), INCHI_COLUMN, values); rows.add(new Row(c.getId(), values)); } }
@Override public Iterator<Column> columns() throws IOException { Set<Column> columns = new LinkedHashSet<Column>(); CompoundIterator rows = new CompoundIterator(this.file); try { while(rows.hasNext()){ Row row = rows.next(); columns.addAll((row.getValues()).keySet()); } } finally { rows.close(); } return columns.iterator(); }
@Override public int hashCode(){ return this.getId().hashCode(); }
static public List<String> formatRowIds(Table table) throws Exception { List<String> result = new ArrayList<String>(); for(Iterator<Row> it = table.rows(); it.hasNext(); ){ Row row = it.next(); result.add(format(row.getId())); } return result; }
public Row getRow(String id) throws Exception { Iterator<Row> rows = rows(); try { while(rows.hasNext()){ Row row = rows.next(); if((row.getId()).equals(id)){ return row; } } } finally { close(rows); } return null; }