Package com.google.visualization.datasource.datatable.value

Examples of com.google.visualization.datasource.datatable.value.NumberValue


    }

    // Make sure the value of the data table cells is correct. For cells with
    // null value, check that the value equals to the null value format of the
    // specific type value.
    assertEquals(new NumberValue(100.0),
        dataTable.getRow(0).getCell(0).getValue());
    assertEquals("Yaron", dataTable.getRow(0).getCell(1).getValue().toString());
    assertEquals(new TextValue(""), dataTable.getRow(0).getCell(2).getValue());
    assertEquals("Bar", dataTable.getRow(1).getCell(2).getValue().toString());
    assertEquals("F", dataTable.getRow(1).getCell(3).getValue().toString());
View Full Code Here


    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(""));
View Full Code Here

    rows = Lists.newArrayList();

    TableRow row = new TableRow();
    row.addCell(new TableCell(new DateValue(2011, 1, 1), "1/1/2011"));
    row.addCell(new TableCell(new DateTimeValue(2011, 1, 1, 0, 0, 0, 0), "1/1/2011 00:00:00"));
    row.addCell(new TableCell(new NumberValue(222), "222"));
    rows.add(row);

    row = new TableRow();
    row.addCell(new TableCell(new DateValue(2011, 1, 2), "1/2/2011"));
    row.addCell(new TableCell(new DateTimeValue(2011, 1, 2, 3, 15, 0, 0)));
View Full Code Here

    rows = Lists.newArrayList();

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

    row = new TableRow();
    row.addCell(new TableCell("bbb"));
    row.addCell(new TableCell(new NumberValue(333)));
    rows.add(row);

    testData.addRows(rows);
    testData.addWarning(new Warning(ReasonType.DATA_TRUNCATED, "Sorry, data truncated"));
    testData.addWarning(new Warning(ReasonType.NOT_SUPPORTED, "foobar"));
View Full Code Here

    rows = Lists.newArrayList();

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

    row = new TableRow();
    row.addCell(new TableCell(""));
    row.addCell(new TableCell(NumberValue.getNullValue()));
View Full Code Here

    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(""));
View Full Code Here

    switch (valueType) {
      case BOOLEAN:
        value = BooleanValue.getInstance(rs.getBoolean(column));
        break;
      case NUMBER:
        value = new NumberValue(rs.getDouble(column));
        break;
      case DATE:
        Date date = rs.getDate(column);
        // If date is null it is handled later.
        if (date != null) {
View Full Code Here

    // Test select.
    DataTable result = DataSourceHelper.applyQuery(DataSourceHelper.parseQuery("select population"),
        data, ULocale.US);
    assertEquals(1, result.getNumberOfColumns());
    assertEquals(4, result.getNumberOfRows());
    assertEquals(new NumberValue(300), result.getRow(1).getCell(0).getValue());

    data = createData();

    // Test where.
    result = DataSourceHelper.applyQuery(DataSourceHelper.parseQuery(
        "select name,vegeterian where population > 100"), data, ULocale.US);
    assertEquals(2, result.getNumberOfColumns());
    assertEquals(1, result.getNumberOfRows());
    assertEquals(new TextValue("Sloth"), result.getRow(0).getCell(0).getValue());
    assertEquals(BooleanValue.TRUE, result.getRow(0).getCell(1).getValue());

    data = createData();

    // Test group by.
    result = DataSourceHelper.applyQuery(DataSourceHelper.parseQuery(
        "select vegeterian,sum(population) group by vegeterian"), data, ULocale.US);
    assertEquals(2, result.getNumberOfColumns());
    assertEquals(2, result.getNumberOfRows());
    assertEquals(BooleanValue.FALSE, result.getRow(0).getCell(0).getValue());
    assertEquals(new NumberValue(130), result.getRow(0).getCell(1).getValue());

    data = createData();

    // Test pivot.
    result = DataSourceHelper.applyQuery(DataSourceHelper.parseQuery(
        "select sum(population) pivot vegeterian"), data, ULocale.US);
    assertEquals(2, result.getNumberOfColumns());
    assertEquals(1, result.getNumberOfRows());
    assertEquals("false", result.getColumnDescription(0).getLabel());
    assertEquals(new NumberValue(130), result.getRow(0).getCell(0).getValue());

    data = createData();

    // Test order by.
    result = DataSourceHelper.applyQuery(DataSourceHelper.parseQuery(
View Full Code Here

    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 =
        new ScalarFunctionColumn(columns, scalarFunction);
    DataTableColumnLookup lookup = new DataTableColumnLookup(table);
    Value value = sfc.getValue(lookup, row);
    Value expectedValueFromDate = new NumberValue(2008);
    assertEquals(expectedValueFromDate, value);

    // Check datetime value.
    List<AbstractColumn> columns1 =
        Lists.newArrayList((AbstractColumn) new SimpleColumn("dateTimeCol"));
    sfc = new ScalarFunctionColumn(columns1, scalarFunction);
    lookup =  new DataTableColumnLookup(table);
    value = sfc.getValue(lookup, row);
    Value expectedValueFromDateTime = new NumberValue(2007);
    assertEquals(value, expectedValueFromDateTime);

    // Check bad input (timeofday value).
    List<AbstractColumn> columns2 =
        Lists.newArrayList((AbstractColumn) new SimpleColumn("timeOfDayCol"));
View Full Code Here

    table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
    table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
    table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));

    ColumnValueFilter filter = new ColumnValueFilter(new SimpleColumn("c2"),
        new NumberValue(100), ComparisonFilter.Operator.GE);
    assertTrue(filter.isMatch(table, row));
    filter = new ColumnValueFilter(new SimpleColumn("c2"),
        new NumberValue(100), ComparisonFilter.Operator.LE, true);
    assertTrue(filter.isMatch(table, row));
    filter = new ColumnValueFilter(new SimpleColumn("c2"),
        new NumberValue(100), ComparisonFilter.Operator.LE);
    assertFalse(filter.isMatch(table, row));
    filter = new ColumnValueFilter(new SimpleColumn("c1"),
        new TextValue("b"), ComparisonFilter.Operator.GT);
    assertFalse(filter.isMatch(table, row));
    filter = new ColumnValueFilter(new SimpleColumn("c1"),
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.datatable.value.NumberValue

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.