@Override public boolean canGet(String field, Class<?> type) { if (!schema.hasColumn(field)) { return false; } return schema.getColumnType(field).equals(type); }
@Override protected boolean hasColumn(String arg0) { return table.getSchema().hasColumn(arg0); }
@Override public Column removeColumn(String arg0) { if (!table.getSchema().hasColumn(arg0)) { return null; } else { return removeColumn(this.getColumnNumber(arg0)); } }
/** * Constructor. * @param inNodeSchema original schema for nodes * @param inEdgeSchema original schema for edges */ public IvtkObviousTree(Schema inNodeSchema, Schema inEdgeSchema) { this.nodeSchema = inNodeSchema; this.edgeSchema = inEdgeSchema; if (!edgeSchema.hasColumn("parent")) { edgeSchema.addColumn("parent", Integer.class, 0); } if (!edgeSchema.hasColumn("child")) { edgeSchema.addColumn("child", Integer.class, 0); } edgeTable = new IvtkObviousTable(edgeSchema); tree = new DefaultTree(); ColumnFactory factory = ColumnFactory.getInstance(); for (int i = 0; i < nodeSchema.getColumnCount(); i++) { Column col = factory.create(nodeSchema.getColumnType(i).getSimpleName(), nodeSchema.getColumnName(i)); tree.addColumn(col); } if (this.forest == null) { this.forest = new ArrayList<Tree<Node, Edge>>(); } if (!this.forest.contains(this)) { this.forest.add(this); } }
@Override public void removeColumn(Column arg0) { if (!table.getSchema().hasColumn(getColumnName(getColumnNumber(arg0)))) { return; } removeColumn(getColumnNumber(arg0)); }
@SuppressWarnings("unchecked") @Override public void addColumn(String arg0, Class arg1, Object arg2) { if (!m_names.contains(arg0)) { if (!table.getSchema().hasColumn(arg0)) { table.getSchema().addColumn(arg0, arg1, arg2); } Column col = ColumnFactory.getColumn(arg1, getRowCount(), arg2); int colIndex = table.getSchema().getColumnIndex(arg0); this.m_lastCol = colIndex; this.m_columns.add(col); this.m_names.add(arg0); ColumnEntry entry = new ColumnEntry(colIndex, col, new ColumnMetadata(this, arg0)); ColumnEntry oldEntry = (ColumnEntry) this.m_entries.put(arg0, entry); if (oldEntry != null) { oldEntry.dispose(); } invalidateSchema(); // listen to what the column has to say col.addColumnListener(this); fireTableEvent(0, getRowCount(), m_lastCol, TableModelEvent.INSERT); } }
/** * Adds a given node to the current graph. * @param node node to add to the graph * @return true if the node is added */ public boolean addNode(Node node) { try { int rowId = graph.addVertex(); for (int i = 0; i < node.getSchema().getColumnCount(); i++) { if (nodeSchema.hasColumn(node.getSchema().getColumnName(i))) { TypedFormat format = formatFactory.getFormat( node.getSchema().getColumnType(i).getSimpleName()); StringBuffer v = format.format(node.get(i), new StringBuffer(), new FieldPosition(0)); graph.getVertexTable().setValueAt(v.toString(), rowId, graph.getVertexTable().indexOf( node.getSchema().getColumnName(i))); } } nodeToId.put(node, rowId); fireNetworkEvent(node.getRow(), node.getRow(), 0, NetworkListener.INSERT_NODE); return true; } catch (Exception e) { throw new ObviousRuntimeException(e); } }
for (int i = 0; i < tuple.getSchema().getColumnCount(); i++) { String field = tuple.getSchema().getColumnName(i); if (schema.hasColumn(field)) { TypedFormat format = formatFactory.getFormat( tuple.getSchema().getColumnType(i).getSimpleName());
/** * Adds an edge to the graph. * @param edge edge to add * @param source source node * @param target target node * @param edgeType unused parameter * @return true if added */ public boolean addEdge(Edge edge, Node source, Node target, obvious.data.Graph.EdgeType edgeType) { try { int edgeId = graph.addEdge(getNodeId(source), getNodeId(target)); for (int i = 0; i < edge.getSchema().getColumnCount(); i++) { if (edgeSchema.hasColumn(edge.getSchema().getColumnName(i))) { TypedFormat format = formatFactory.getFormat( edge.getSchema().getColumnType(i).getSimpleName()); StringBuffer v = format.format(edge.get(i), new StringBuffer(), new FieldPosition(0)); graph.getEdgeTable().setValueAt(v.toString(), edgeId, graph.getEdgeTable().indexOf(edge.getSchema().getColumnName(i))); } } edgeToId.put(edge, edgeId); fireNetworkEvent(edge.getRow(), edge.getRow(), 0, NetworkListener.INSERT_EDGE); return true; } catch (Exception e) { throw new ObviousRuntimeException(e); } }
String[] schemaCol = new String[schemaSize + 1]; for (int i = schemaSize; i >= 0; i--) { schemaBoolean[i] = tuple.getSchema().hasColumn( visualTable.getColumnName(i)); schemaCol[i] = visualTable.getColumnName(i);