@Override public String toString() { StringBuffer text = new StringBuffer(); for (int i = 0; i < tuple.getSchema().getColumnCount(); i++) { if (i > 0) text.append(","); text.append(tuple.get(i)); } return text.toString(); }
@Override public double value(int attIndex) { Class<?> c = tuple.getSchema().getColumnType(attIndex); double value = -1; if (ObviousWekaUtils.isNumeric(c)) { return Double.valueOf(tuple.get(attIndex).toString()); } else if (ObviousWekaUtils.isString(c)) { return Double.valueOf(attribute(attIndex).indexOfValue( tuple.getString(attIndex))); } else if (ObviousWekaUtils.isDate(c)) { return tuple.getDate(attIndex).getTime(); } return value; }
@Override public int addRow(Tuple tuple) { if (tuple.getSchema().equals(getSchema())) { String colName = tuple.getString("name"); Class<?> c = (Class<?>) tuple.get("type"); Object value = tuple.get("default"); addColumn(colName, c, value); } this.fireTableEvent(getColumnCount(), getColumnCount(), TableListener.ALL_COLUMN, TableListener.INSERT); return getColumnCount(); }
@Override public int addRow(Tuple tuple) { Schema tupleSchema = tuple.getSchema(); for (int i = 0; i < tupleSchema.getColumnCount(); i++) { if (!tupleSchema.getColumnName(i).equals(schema.getColumnName(i)) || !tupleSchema.getColumnType(i).equals(schema.getColumnType(i))) { return -1; } } Instance inst = new Instance(schema.getColumnCount()); for (int i = 0; i < tuple.getSchema().getColumnCount(); i++) { Attribute att = instances.attribute(i); if (att.isNumeric()) { inst.setValue(att, Double.parseDouble(tuple.get(i).toString())); } else if (att.isString() || att.isNominal()) { inst.setValue(att, tuple.getString(i)); } else if (att.isDate()) { try { inst.setValue(att, att.parseDate(tuple.getDate(i).toString())); } catch (ParseException e) { e.printStackTrace(); } } } instances.add(inst); return getRowCount(); }
/** * Adds a row to the table (tuple). * @param tuple tuple to insert in the table. * @return row count */ public int addRow(Tuple tuple) { try { this.beginEdit(TableListener.ALL_COLUMN); int r = table.addRow(); for (int i = 0; i < tuple.getSchema().getColumnCount(); i++) { this.set(r, tuple.getSchema().getColumnName(i), tuple.get(i)); } this.endEdit(TableListener.ALL_COLUMN); this.fireTableEvent(r, r, TableListener.ALL_COLUMN, TableListener.INSERT); return r; } catch (Exception e) { throw new ObviousRuntimeException(e); } }
tuple.getSchema().getColumnType(i).getSimpleName()); if (format instanceof FormatFactoryImpl.TypedDecimalFormat) { table.setValueAt(tuple.get(i).toString(), rowId, schema.getColumnIndex(field)); } else { StringBuffer v = format.format(tuple.get(i), new StringBuffer(), new FieldPosition(0)); table.setValueAt(v.toString(), rowId, schema.getColumnIndex(field));
for (int j = schemaSize; j >= 0; j--) { if (schemaBoolean[i] && !visualTable.get(i, schemaCol[j]).equals( tuple.get(schemaCol[j]))) { find = false; break;