/** * Gets a specific value. * @param rowId spotted row * @param field field dedicated to spotted column * @return value */ public Object getValue(int rowId, String field) { return this.schemaTable.getValue(rowId, field); }
@Override public Object getObjectAt(int index) { return table.getValue(index, id); }
public Object get(int arg0, int arg1) { return table.getValue(arg0, arg1); }
@Override public Object get(int arg0, String arg1) { return table.getValue(arg0, arg1); }
/** * Gets a specific value. * @param rowId spotted row * @param col spotted column * @return value */ public Object getValue(int rowId, int col) { return this.schemaTable.getValue(rowId, col); }
/** * Gets the value at a specified row and column indexes. * @param rowIndex index of the row where to get value * @param columnIndex index of the column where to get value * @return a value */ public Object getValueAt(int rowIndex, int columnIndex) { return table.getValue(rowIndex, columnIndex); }
/** * Returns the value for the cell at columnIndex and rowIndex. * @param rowIndex - the row whose value is to be queried * @param columnIndex - the column whose value is to be queried * @return the value Object at the specified cell */ public Object getValueAt(int rowIndex, int columnIndex) { if (table.isValidRow(rowIndex)) { return this.table.getValue(rowIndex, columnIndex); } else { return null; } }
@Override public String getValueAt(int index) { return format(table.getValue(index, id)); }
@Override public boolean isValueUndefined(int i) { if (i < 0 || i >= size()) { return true; } return table.getValue(i, id) == null; }
/** * Gets the parent node. * @param node a node of the tree * @return parent node */ public Node getParentNode(Node node) { Node parent = null; for (int i = 0; i < edgeTable.getRowCount(); i++) { if (getNodeId(node) == edgeTable.getValue(i, "child")) { for (Map.Entry<Node, Integer> e : nodeToId.entrySet()) { if (e.getValue() == edgeTable.getValue(i, "parent")) { parent = e.getKey(); break; } } } } return parent; }
/** * Gets a collection of children of a node in the tree. * @param node a node of the tree * @return children of the node */ public Collection<Node> getChildNodes(Node node) { Collection<Node> children = new ArrayList<Node>(); for (int i = 0; i < edgeTable.getRowCount(); i++) { if (getNodeId(node) == edgeTable.getValue(i, "parent")) { for (Map.Entry<Node, Integer> e : nodeToId.entrySet()) { if (e.getValue() == edgeTable.getValue(i, "child")) { children.add(e.getKey()); } } } } return children; }
/** * Gets the target (child) node of a directed edge. * @param directedEdge an edge of the tree * @return target (child) node */ public Node getTarget(Edge directedEdge) { Node target = null; Integer targetId = (Integer) edgeTable.getValue(getEdgeId(directedEdge), "child"); for (Map.Entry<Node, Integer> e : nodeToId.entrySet()) { if (e.getValue() == targetId && tree.isRowValid(targetId)) { target = e.getKey(); break; } } return target; }
/** * Gets the source (parent) node of a directed edge. * @param directedEdge an edge of the tree * @return source (parent) node */ public Node getSource(Edge directedEdge) { Node source = null; Integer sourceId = (Integer) edgeTable.getValue(getEdgeId(directedEdge), "parent"); for (Map.Entry<Node, Integer> e : nodeToId.entrySet()) { if (e.getValue() == sourceId && tree.isRowValid(sourceId)) { source = e.getKey(); break; } } return source; }
@Override public Object get(int col) { return getTable().getValue(getRow(), col); }
/** * Gets a collection of child Edges of a node in the tree. * @param node a node of the tree * @return child edges of the tree */ public Collection<Edge> getChildEdges(Node node) { Collection<Edge> children = new ArrayList<Edge>(); for (int i = 0; i < edgeTable.getRowCount(); i++) { if (getNodeId(node) == edgeTable.getValue(i, "parent")) { children.add(new EdgeImpl(edgeTable, i)); } } return children; }
/** * Gets for two nodes the connecting edge. * @param v1 first node * @param v2 second node * @return connecting edge */ public Edge getConnectingEdge(Node v1, Node v2) { Edge connecting = null; int v1Id = getNodeId(v1); int v2Id = getNodeId(v2); for (int i = 0; i < edgeTable.getRowCount(); i++) { int parentId = (Integer) edgeTable.getValue(i, "parent"); int childId = (Integer) edgeTable.getValue(i, "child"); if ((v1Id == parentId && v2Id == childId) || (v2Id == parentId && v1Id == childId)) { connecting = new EdgeImpl(edgeTable, i); } } return connecting; }
/** * Gets the parent edge. * @param node a node of the tree * @return parent edge */ public Edge getParentEdge(Node node) { Edge parent = null; for (int i = 0; i < edgeTable.getRowCount(); i++) { if (getNodeId(node) == edgeTable.getValue(i, "child")) { parent = new EdgeImpl(edgeTable, i); } } return parent; }
@Override public Column getColumn(int arg0) { Column column = ColumnFactory.getColumn(getColumnType(arg0), getRowCount(), this.getSchema().getDefault(arg0)); IntIterator it = this.rows(); while (it.hasNext()) { int currentRow = it.nextInt(); column.set(table.getValue(currentRow, arg0), currentRow); } return column; }
@Override public Tuple getTuple(int arg0) { if (this.isValidRow(arg0)) { Object[] values = new Object[table.getSchema().getColumnCount()]; for (int i = 0; i < table.getSchema().getColumnCount(); i++) { values[i] = table.getValue(arg0, i); } return new WrapToPrefTuple(new TupleImpl(table.getSchema(), values), arg0); } else { return null; } }
@Override public Attribute attribute(int index) { if (index >= table.getSchema().getColumnCount()) { return null; } FastVector fastVect = new FastVector(); Class<?> c = table.getSchema().getColumnType(index); IntIterator iter = table.rowIterator(); while (iter.hasNext()) { int row = iter.nextInt(); if (!fastVect.contains(table.getValue(row, index))) { fastVect.addElement(table.getValue(row, index)); } } if (ObviousWekaUtils.isNumeric(c)) { return new Attribute(table.getSchema().getColumnName(index)); } else if (ObviousWekaUtils.isString(c)) { return new Attribute(table.getSchema().getColumnName(index), fastVect); } else if (ObviousWekaUtils.isDate(c)) { return new Attribute(table.getSchema().getColumnName(index), "yyyy-MM-dd", null); } return new Attribute(table.getSchema().getColumnName(index)); }