Package com.google.visualization.datasource.datatable

Examples of com.google.visualization.datasource.datatable.TableRow


    dataTable.addColumn(c1);
    dataTable.addColumn(c2);

    List<TableRow> rows = Lists.newArrayList();

    TableRow row = new TableRow();
    row.addCell(new TableCell("aaa"));
    row.addCell(new TableCell(new NumberValue(222), "222"));
    row.addCell(new TableCell(false));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell(""));
    row.addCell(new TableCell(111));
    row.addCell(new TableCell(true));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell((new TextValue("bbb")), "bbb"));
    row.addCell(new TableCell(333));
    row.addCell(new TableCell(true));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell("ddd"));
    row.addCell(new TableCell(222));
    row.addCell(new TableCell(false));
    rows.add(row);
    dataTable.addRows(rows);

    return dataTable;
  }
View Full Code Here


      TableCell cell;
      ColumnDescription columnDescription;

      List<TableRow> rows = dataTable.getRows();
      for (int rowId = 0; rowId < rows.size(); rowId++) {
        TableRow tableRow = rows.get(rowId);
        cells = tableRow.getCells();
        sb.append("{\"c\":[");
        for (int cellId = 0; cellId < cells.size(); cellId++) {
          cell = cells.get(cellId);
          if (cellId < (cells.size() - 1)) {
            appendCellJson(cell, sb, includeFormatting, false, renderDateAsDateConstructor);
            sb.append(",");
          } else {
            // Last column in the row.
            appendCellJson(cell, sb, includeFormatting, true, renderDateAsDateConstructor);
          }
        }
        sb.append("]");

        // Row properties.
        String customPropertiesString = getPropertiesMapString(tableRow.getCustomProperties());
        if (customPropertiesString != null) {
          sb.append(",\"p\":").append(customPropertiesString);
        }

        sb.append("}"); // cells.
View Full Code Here

    }

    // Build the data table rows, and in each row create the table cells with
    // the information in the result set.
    while (rs.next()) {
      TableRow tableRow = new TableRow();
      for (int c = 0; c < numOfCols; c++) {
        tableRow.addCell(buildTableCell(rs, columnsTypeArray[c], c));
      }
      try {
        dataTable.addRow(tableRow);
      } catch (TypeMismatchException e) {
        // Should not happen. An SQLException would already have been thrown if there was such a
View Full Code Here

    // Check with simple data table and simple data source parameters.
    DataTable dataTable = new DataTable();
    dataTable.addColumn(new ColumnDescription("col1", ValueType.NUMBER, "column1"));
    dataTable.addColumn(new ColumnDescription("col2", ValueType.BOOLEAN, "column2"));
    dataTable.addColumn(new ColumnDescription("col3", ValueType.TEXT, "column3"));
    TableRow tableRow = new TableRow();
    tableRow.addCell(7);
    tableRow.addCell(false);
    tableRow.addCell("Why?");
    dataTable.addRow(tableRow);

    DataSourceRequest dataSourceRequest = new DataSourceRequest(
        new Query(),
        new DataSourceParameters(null),
View Full Code Here

    table.addColumn(new ColumnDescription("dateCol", ValueType.DATE, "dateCol"));
    table.addColumn(new ColumnDescription("numberCol", ValueType.NUMBER, "numberCol"));
    table.addColumn(new ColumnDescription("timeOfDayCol", ValueType.TIMEOFDAY, "timeOfDayCol"));
    table.addColumn(new ColumnDescription("dateTimeCol", ValueType.DATETIME, "dateTimeCol"));

    TableRow row = new TableRow();
    row.addCell(new TableCell(new DateValue(2008, 5, 3)));
    row.addCell(new TableCell(new NumberValue(23)));
    row.addCell(new TableCell(new TimeOfDayValue(13, 12, 11)));
    row.addCell(new TableCell(new DateTimeValue(2007, 3, 4, 2, 6, 23, 120)));

    // Check date value.
    List<AbstractColumn> columns =
        Lists.newArrayList((AbstractColumn) new SimpleColumn("dateCol"));
     ScalarFunctionColumn sfc =
View Full Code Here

*
* @author Yonatan B.Y.
*/
public class ColumnColumnFilterTest extends TestCase {
  public void testMatch() {
    TableRow row = new TableRow();
    row.addCell(new TableCell("a"));
    row.addCell(new TableCell(123));
    row.addCell(new TableCell("a"));

    DataTable table = new DataTable();
    table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
    table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
    table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));
View Full Code Here

        new SimpleColumn("c3"), ComparisonFilter.Operator.LE);
    assertTrue(filter.isMatch(table, row));
  }

  public void testNoMatch() {
    TableRow row = new TableRow();
    row.addCell(new TableCell("a"));
    row.addCell(new TableCell(123));
    row.addCell(new TableCell("a"));

    DataTable table = new DataTable();
    table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
    table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
    table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));
View Full Code Here

* @author Yonatan B.Y.
*/
public class ColumnValueFilterTest extends TestCase {

  public void testVariousFilters() {
    TableRow row = new TableRow();
    row.addCell(new TableCell("a"));
    row.addCell(new TableCell(123));
    row.addCell(new TableCell("a"));

    DataTable table = new DataTable();
    table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
    table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
    table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));
View Full Code Here

    DataTable res = new DataTable();
    res.addColumns(dataTables[tableNum].getColumnDescriptions());
    res = res.clone(); // Clones the column descriptions.
    try {
      for (int i = 0; i < numRows; i++) {
        TableRow row = new TableRow();
        for (ColumnDescription colDesc : res.getColumnDescriptions()) {
          Value value = toRandomValue(colDesc.getType());
          row.addCell(new TableCell(value));
        }
        res.addRow(row);
      }
    } catch (TypeMismatchException e) {
        // Should not happen, as we control the types.
View Full Code Here

   *
   * @return A table row.
   */
  public static TableRow createNewTableRow(String[] content,
      List<ColumnDescription> descriptors) {
    TableRow result = new TableRow();
    for (int i = 0; i < content.length; i++) {
      Value value = toValue(content[i], descriptors.get(i).getType());
      result.addCell(new TableCell(value));
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.datatable.TableRow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.