public String[] getStringRow(int row) { String[] outgoing = new String[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getString(row, col); } return outgoing; }
/** * @param column ID number of the column to search */ public String[] getStringColumn(int column) { String[] outgoing = new String[rowCount]; for (int i = 0; i < rowCount; i++) { outgoing[i] = getString(i, column); } return outgoing; }
public String[] getStringRow(int row) { String[] outgoing = new String[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getString(row, col); } return outgoing; }
/** * @param column ID number of the column to search */ public String[] getStringColumn(int column) { String[] outgoing = new String[rowCount]; for (int i = 0; i < rowCount; i++) { outgoing[i] = getString(i, column); } return outgoing; }
public String getString(String columnName) { return table.getString(row, columnName); }
public String getString(int column) { return table.getString(row, column); }
public String getString(String columnName) { return table.getString(row, columnName); }
public String getString(int column) { return table.getString(row, column); }
/** * @param columnName title of the column to reference */ public String getString(int row, String columnName) { return getString(row, getColumnIndex(columnName)); }
/** * @param columnName title of the column to reference */ public String getString(int row, String columnName) { return getString(row, getColumnIndex(columnName)); }
public long getLong(int row, int column) { checkBounds(row, column); if (columnTypes[column] == LONG) { long[] longData = (long[]) columns[column]; return longData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { return missingLong; } try { return Long.parseLong(str); } catch (NumberFormatException nfe) { return missingLong; } }
public long getLong(int row, int column) { checkBounds(row, column); if (columnTypes[column] == LONG) { long[] longData = (long[]) columns[column]; return longData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { return missingLong; } try { return Long.parseLong(str); } catch (NumberFormatException nfe) { return missingLong; } }
public double getDouble(int row, int column) { checkBounds(row, column); if (columnTypes[column] == DOUBLE) { double[] doubleData = (double[]) columns[column]; return doubleData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { return missingDouble; } try { return Double.parseDouble(str); } catch (NumberFormatException nfe) { return missingDouble; } }
public double getDouble(int row, int column) { checkBounds(row, column); if (columnTypes[column] == DOUBLE) { double[] doubleData = (double[]) columns[column]; return doubleData[row]; } String str = getString(row, column); if (str == null || str.equals(missingString)) { return missingDouble; } try { return Double.parseDouble(str); } catch (NumberFormatException nfe) { return missingDouble; } }
protected void writeHTML(PrintWriter writer) { writer.println("<html>"); writer.println("<head>"); writer.println(" <meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />"); writer.println("</head>"); writer.println("<body>"); writer.println(" <table>"); for (int row = 0; row < getRowCount(); row++) { writer.println(" <tr>"); for (int col = 0; col < getColumnCount(); col++) { String entry = getString(row, col); writer.print(" <td>"); writeEntryHTML(writer, entry); writer.println(" </td>"); } writer.println(" </tr>"); } writer.println(" </table>"); writer.println("</body>"); writer.println("</hmtl>"); writer.flush(); }
/** * @webref table:method * @brief Get an integer value from the specified row and column * @param row ID number of the row to reference * @param column ID number of the column to reference * @see Table#getFloat(int, int) * @see Table#getString(int, int) * @see Table#getStringColumn(String) * @see Table#setInt(int, int, int) * @see Table#setFloat(int, int, float) * @see Table#setString(int, int, String) */ public int getInt(int row, int column) { checkBounds(row, column); if (columnTypes[column] == INT || columnTypes[column] == CATEGORY) { int[] intData = (int[]) columns[column]; return intData[row]; } String str = getString(row, column); return (str == null || str.equals(missingString)) ? missingInt : PApplet.parseInt(str, missingInt); }
@Override public float compare(int index1, int index2) { int a = reverse ? order[index2] : order[index1]; int b = reverse ? order[index1] : order[index2]; switch (getColumnType(column)) { case INT: return getInt(a, column) - getInt(b, column); case LONG: return getLong(a, column) - getLong(b, column); case FLOAT: return getFloat(a, column) - getFloat(b, column); case DOUBLE: return (float) (getDouble(a, column) - getDouble(b, column)); case STRING: return getString(a, column).compareToIgnoreCase(getString(b, column)); case CATEGORY: return getInt(a, column) - getInt(b, column); default: throw new IllegalArgumentException("Invalid column type: " + getColumnType(column)); } }
@Override public float compare(int index1, int index2) { int a = reverse ? order[index2] : order[index1]; int b = reverse ? order[index1] : order[index2]; switch (getColumnType(column)) { case INT: return getInt(a, column) - getInt(b, column); case LONG: return getLong(a, column) - getLong(b, column); case FLOAT: return getFloat(a, column) - getFloat(b, column); case DOUBLE: return (float) (getDouble(a, column) - getDouble(b, column)); case STRING: return getString(a, column).compareToIgnoreCase(getString(b, column)); case CATEGORY: return getInt(a, column) - getInt(b, column); default: throw new IllegalArgumentException("Invalid column type: " + getColumnType(column)); } }
protected Table createSubset(int[] rowSubset) { Table newbie = new Table(); newbie.setColumnTitles(columnTitles); // also sets columns.length newbie.columnTypes = columnTypes; newbie.setRowCount(rowSubset.length); for (int i = 0; i < rowSubset.length; i++) { int row = rowSubset[i]; for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case STRING: newbie.setString(i, col, getString(row, col)); break; case INT: newbie.setInt(i, col, getInt(row, col)); break; case LONG: newbie.setLong(i, col, getLong(row, col)); break; case FLOAT: newbie.setFloat(i, col, getFloat(row, col)); break; case DOUBLE: newbie.setDouble(i, col, getDouble(row, col)); break; } } } return newbie; }
protected Table createSubset(int[] rowSubset) { Table newbie = new Table(); newbie.setColumnTitles(columnTitles); // also sets columns.length newbie.columnTypes = columnTypes; newbie.setRowCount(rowSubset.length); for (int i = 0; i < rowSubset.length; i++) { int row = rowSubset[i]; for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case STRING: newbie.setString(i, col, getString(row, col)); break; case INT: newbie.setInt(i, col, getInt(row, col)); break; case LONG: newbie.setLong(i, col, getLong(row, col)); break; case FLOAT: newbie.setFloat(i, col, getFloat(row, col)); break; case DOUBLE: newbie.setDouble(i, col, getDouble(row, col)); break; } } } return newbie; }