|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.visualization.datasource.datatable.DataTable
public class DataTable
A table of data, arranged in typed columns.
An instance of this class is the result of a request to a data source. A DataTable
can be rendered in many ways: JSON, HTML, CSV (see
com.google.visualization.datasource.render), and can be manipulated using queries (see
Query and
QueryEngine).
A table contains any number of typed columns (see (@link ColumnDescription}) each with an id and
a label, and any number of rows. Each row must have as many cells as there are columns
in the table, and the types of values in the cells must match the types of the columns.
Each cell contains, as well as the typed value, a formatted value of type string, used for
display purposes.
Also, you can use the custom properties mechanism to hold any other data you require. There are
custom properties on every cell, row, column, and on the entire table.
| Constructor Summary | |
|---|---|
DataTable()
Create a new empty result. |
|
| Method Summary | |
|---|---|
void |
addColumn(ColumnDescription columnDescription)
Add a column to the table. |
void |
addColumns(java.util.Collection<ColumnDescription> columnsToAdd)
Adds columns to the table. |
void |
addRow(TableRow row)
Adds a single row to the end of the result. |
void |
addRowFromValues(java.lang.Object... values)
A convenience method for creating a row directly from its cell values and adding it to the data table. |
void |
addRows(java.util.Collection<TableRow> rowsToAdd)
Adds a collection of rows to the end of the result. |
void |
addWarning(Warning warning)
Adds a warning. |
DataTable |
clone()
Returns a new data table, with the same data and metadata as this one. |
boolean |
containsAllColumnIds(java.util.Collection<java.lang.String> colIds)
Check that all the cols in colIds are in the data. |
boolean |
containsColumn(java.lang.String columnId)
Returns whether or not the table contains a column named columnId. |
static DataTable |
createSingleCellTable(java.lang.String str)
Returns a data table with str as the content of its single cell. |
TableCell |
getCell(int rowIndex,
int colIndex)
Returns the cell at the specified row and column indexes. |
java.util.List<TableCell> |
getColumnCells(int columnIndex)
Returns the list of all cells of a certain column, by the column index. |
java.util.List<TableCell> |
getColumnCells(java.lang.String columnId)
Returns the list of all cells of a certain column, by the column Id. |
ColumnDescription |
getColumnDescription(int colIndex)
Returns the column description of a column by its index. |
ColumnDescription |
getColumnDescription(java.lang.String columnId)
Returns the column description of a column by it's id. |
java.util.List<ColumnDescription> |
getColumnDescriptions()
Returns the list of all column descriptions. |
java.util.List<TableCell> |
getColumnDistinctCellsSorted(int columnIndex,
java.util.Comparator<TableCell> comparator)
Returns a sorted list of distinct table cells in the specified column. |
int |
getColumnIndex(java.lang.String columnId)
Returns the column index in the columns of a row (first is zero). |
java.util.Map<java.lang.String,java.lang.String> |
getCustomProperties()
Returns an immutable map of the custom properties. |
java.lang.String |
getCustomProperty(java.lang.String key)
Retrieves a custom property. |
int |
getNumberOfColumns()
Returns the number of columns in this data table. |
int |
getNumberOfRows()
Returns the number of rows in this data table. |
TableRow |
getRow(int rowIndex)
Returns the row at the given index. |
java.util.List<TableRow> |
getRows()
Returns the list of all table rows. |
Value |
getValue(int rowIndex,
int colIndex)
Returns the value in the cell at the specified row and column indexes. |
java.util.List<Warning> |
getWarnings()
Returns the list of warnings in this table. |
void |
setCustomProperty(java.lang.String propertyKey,
java.lang.String propertyValue)
Sets a custom property. |
void |
setRows(java.util.Collection<TableRow> rows)
Sets a collection of rows after clearing any current rows. |
java.lang.String |
toString()
Returns a string representation of the data table. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DataTable()
| Method Detail |
|---|
public void addRow(TableRow row)
throws TypeMismatchException
row - The row of values.
TypeMismatchException - Thrown if the values in the cells do not match the columns.
public void addRowFromValues(java.lang.Object... values)
throws TypeMismatchException
values - The row values.
TypeMismatchException - Thrown if a value does not match its
corresponding column.
public void addRows(java.util.Collection<TableRow> rowsToAdd)
throws TypeMismatchException
rowsToAdd - The row collection.
TypeMismatchException
public void setRows(java.util.Collection<TableRow> rows)
throws TypeMismatchException
rows - The row collection.
TypeMismatchExceptionpublic java.util.List<TableRow> getRows()
public TableRow getRow(int rowIndex)
rowIndex - the index of the requested row.
public int getNumberOfRows()
public int getNumberOfColumns()
public java.util.List<ColumnDescription> getColumnDescriptions()
public ColumnDescription getColumnDescription(int colIndex)
colIndex - The column index.
public ColumnDescription getColumnDescription(java.lang.String columnId)
columnId - The id of the column.
public java.util.List<TableCell> getColumnCells(int columnIndex)
columnIndex - The index of the requested column.
public void addColumn(ColumnDescription columnDescription)
columnDescription - The column's description.public void addColumns(java.util.Collection<ColumnDescription> columnsToAdd)
columnsToAdd - The columns to add.public int getColumnIndex(java.lang.String columnId)
columnId - The id of the column.
public java.util.List<TableCell> getColumnCells(java.lang.String columnId)
columnId - The id of the requested column.
public TableCell getCell(int rowIndex,
int colIndex)
rowIndex - The row index.colIndex - The column index.
public Value getValue(int rowIndex,
int colIndex)
rowIndex - The row index.colIndex - The column index.
public java.util.List<Warning> getWarnings()
public java.util.List<TableCell> getColumnDistinctCellsSorted(int columnIndex,
java.util.Comparator<TableCell> comparator)
columnIndex - The index of the required column.comparator - A Comparator for TableCells.
public void addWarning(Warning warning)
warning - The warning to add.public boolean containsColumn(java.lang.String columnId)
columnId - The column id to check.
public boolean containsAllColumnIds(java.util.Collection<java.lang.String> colIds)
colIds - A list of column ids.
public static DataTable createSingleCellTable(java.lang.String str)
str - The cell's content
public DataTable clone()
clone in class java.lang.Objectpublic java.lang.String getCustomProperty(java.lang.String key)
key - The property key.
public void setCustomProperty(java.lang.String propertyKey,
java.lang.String propertyValue)
propertyKey - The property key.propertyValue - The property value.public java.util.Map<java.lang.String,java.lang.String> getCustomProperties()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||