Examples of NumberValue


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

      fail();
    } catch (UnsupportedOperationException e) {
      // Expected behavior.
    }

    assertEquals(new NumberValue(2), aggregator.getValue(AggregationType.COUNT));
    assertEquals(new TextValue("a"), aggregator.getValue(AggregationType.MIN));
    assertEquals(new TextValue("b"), aggregator.getValue(AggregationType.MAX));

  }
View Full Code Here

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

  }

  public void testGetValueFromEmptyAggregation() {
    ValueAggregator aggregator = new ValueAggregator(ValueType.DATE);
    DateValue dateNull = DateValue.getNullValue();
    NumberValue numberNull = NumberValue.getNullValue();

    assertEquals(new NumberValue(0), aggregator.getValue(AggregationType.COUNT));

    assertEquals(dateNull, aggregator.getValue(AggregationType.MIN));
    assertEquals(dateNull, aggregator.getValue(AggregationType.MAX));

    assertEquals(numberNull, aggregator.getValue(AggregationType.AVG));
View Full Code Here

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

    TableRow row;

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("aaa")));
    row.addCell(new TableCell(new NumberValue(222)));
    row.addCell(new TableCell(BooleanValue.TRUE, "T"));
    input.addRow(row);

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("ccc")));
    row.addCell(new TableCell(new NumberValue(111)));
    row.addCell(new TableCell(BooleanValue.TRUE, "T"));
    input.addRow(row);

    row = new TableRow();
    row.addCell(new TableCell(new TextValue("bbb")));
    row.addCell(new TableCell(new NumberValue(333)));
    row.addCell(new TableCell(BooleanValue.FALSE, "F"));
    input.addRow(row);
  }
View Full Code Here

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

    selection.addColumn(col1);
    selection.addColumn(col2);
    q.setSelection(selection);

    // Add Filter
    QueryFilter filter = new ColumnValueFilter(col3, new NumberValue(-5),
        ComparisonFilter.Operator.GT);
    q.setFilter(filter);

    q.validate();
View Full Code Here

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

    // selection with modulo ('weight' is a column id): "select weight, weight % 10"
    Query q = new Query();

    AbstractColumn col1 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(), new Constant(new NumberValue(10)));
    AbstractColumn col2 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("weight"), col1),
        Modulo.getInstance());

    // Add selection
View Full Code Here

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

    selection.addColumn(new SimpleColumn("name"));
    selection.addColumn(new SimpleColumn("weight"));
    q.setSelection(selection);

    AbstractColumn col1 = new ScalarFunctionColumn(
      Lists.<AbstractColumn>newArrayList(), new Constant(new NumberValue(2)));
    AbstractColumn col2 = new ScalarFunctionColumn(
      Lists.<AbstractColumn>newArrayList(new SimpleColumn("weight"), col1),
      Modulo.getInstance());

    QueryFilter filter = new ColumnValueFilter(col2,
      new NumberValue(0), ComparisonFilter.Operator.EQ);
    q.setFilter(filter);
 
    q.validate();

    DataTable result = QueryEngine.executeQuery(q, res, ULocale.US);
View Full Code Here

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

    Query query = new Query();
    QuerySelection selection = new QuerySelection(); // SELECT (sum(sales) / 7)
    List<AbstractColumn> columns = Lists.newArrayList();
    columns.add(new AggregationColumn(new SimpleColumn("Sales"), AggregationType.SUM));
    columns.add(new ScalarFunctionColumn(Lists.<AbstractColumn>newArrayList(),
        new Constant(new NumberValue(7))));
    AbstractColumn selectedColumn = new ScalarFunctionColumn(columns, Quotient.getInstance());
    selection.addColumn(selectedColumn);

    query.setSelection(selection);
    QueryGroup group = new QueryGroup();
View Full Code Here

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

    columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
    columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
    dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
    assertEquals(3, dataTable.getNumberOfRows());
    assertEquals(3, dataTable.getNumberOfColumns());
    assertEquals(new NumberValue(1), dataTable.getRow(0).getCell(0).getValue());
    assertEquals(new TextValue("a"), dataTable.getRow(0).getCell(1).getValue());
    assertEquals(DateValue.getNullValue(), dataTable.getRow(0).getCell(2).getValue());
    assertEquals(new NumberValue(4), dataTable.getRow(1).getCell(0).getValue());
    assertEquals(new TextValue("x13a"), dataTable.getRow(1).getCell(1).getValue());
    assertEquals(DateValue.getNullValue(), dataTable.getRow(1).getCell(2).getValue());
    assertEquals(new NumberValue(1400), dataTable.getRow(2).getCell(0).getValue());
    assertEquals(new TextValue("4"), dataTable.getRow(2).getCell(1).getValue());
    assertEquals(DateValue.getNullValue(), dataTable.getRow(2).getCell(2).getValue());

    // Working example with a table description filled only with types.
    reader = new StringReader("1,a,2004-03-01\n4,x13a,2005-04-02\n1400,4,2006-05-03");
    columnDescriptions = Lists.newArrayList();
    columnDescriptions.add(new ColumnDescription("i1", ValueType.NUMBER, null));
    columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
    columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
    dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
    assertEquals(3, dataTable.getNumberOfRows());
    assertEquals(3, dataTable.getNumberOfColumns());
    assertEquals(new NumberValue(1), dataTable.getRow(0).getCell(0).getValue());
    assertEquals(new TextValue("a"), dataTable.getRow(0).getCell(1).getValue());
    assertEquals(new DateValue(2004, 2, 1), dataTable.getRow(0).getCell(2).getValue());
    assertEquals(new NumberValue(4), dataTable.getRow(1).getCell(0).getValue());
    assertEquals(new TextValue("x13a"), dataTable.getRow(1).getCell(1).getValue());
    assertEquals(new DateValue(2005, 3, 2), dataTable.getRow(1).getCell(2).getValue());
    assertEquals(new NumberValue(1400), dataTable.getRow(2).getCell(0).getValue());
    assertEquals(new TextValue("4"), dataTable.getRow(2).getCell(1).getValue());
    assertEquals(new DateValue(2006, 4, 3), dataTable.getRow(2).getCell(2).getValue());
    assertEquals("i1", dataTable.getColumnDescription(0).getId());
    assertEquals("Column0", dataTable.getColumnDescription(0).getLabel());
    assertEquals("i2", dataTable.getColumnDescription(1).getId());
    assertEquals("Column1", dataTable.getColumnDescription(1).getLabel());
    assertEquals("i3", dataTable.getColumnDescription(2).getId());
    assertEquals("Column2", dataTable.getColumnDescription(2).getLabel());

    // Working example with header rows.
    reader = new StringReader("1,a,2004-03-01\n4,x13a,2005-04-02\n1400,4,2006-05-03");
    columnDescriptions = Lists.newArrayList();
    columnDescriptions.add(new ColumnDescription("i1", ValueType.NUMBER, null));
    columnDescriptions.add(new ColumnDescription("i2", ValueType.TEXT, null));
    columnDescriptions.add(new ColumnDescription("i3", ValueType.DATE, null));
    dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, true);
    assertEquals(2, dataTable.getNumberOfRows());
    assertEquals(3, dataTable.getNumberOfColumns());
    assertEquals(new NumberValue(4), dataTable.getRow(0).getCell(0).getValue());
    assertEquals(new TextValue("x13a"), dataTable.getRow(0).getCell(1).getValue());
    assertEquals(new DateValue(2005, 3, 2), dataTable.getRow(0).getCell(2).getValue());
    assertEquals(new NumberValue(1400), dataTable.getRow(1).getCell(0).getValue());
    assertEquals(new TextValue("4"), dataTable.getRow(1).getCell(1).getValue());
    assertEquals(new DateValue(2006, 4, 3), dataTable.getRow(1).getCell(2).getValue());
    assertEquals("i1", dataTable.getColumnDescription(0).getId());
    assertEquals("1",  dataTable.getColumnDescription(0).getLabel());
    assertEquals("i2", dataTable.getColumnDescription(1).getId());
View Full Code Here

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

    columnDescriptions.add(columnDescription);
   
    DataTable dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, true);
    assertEquals(2, dataTable.getNumberOfRows());
    assertEquals(3, dataTable.getNumberOfColumns());
    assertEquals(new NumberValue(4), dataTable.getRow(0).getCell(0).getValue());
    assertEquals(new TextValue("x13a"), dataTable.getRow(0).getCell(1).getValue());
    assertEquals(new DateValue(2005, 3, 2), dataTable.getRow(0).getCell(2).getValue());
    assertEquals(new NumberValue(1400), dataTable.getRow(1).getCell(0).getValue());
    assertEquals(new TextValue("4"), dataTable.getRow(1).getCell(1).getValue());
    assertEquals(new DateValue(2006, 4, 3), dataTable.getRow(1).getCell(2).getValue());
    assertEquals("i1", dataTable.getColumnDescription(0).getId());
    assertEquals("1",  dataTable.getColumnDescription(0).getLabel());
    assertEquals("i2", dataTable.getColumnDescription(1).getId());
View Full Code Here

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

    columnDescriptions.add(new ColumnDescription("i3", ValueType.NUMBER, null));
      
    DataTable dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, true);
    assertEquals(1, dataTable.getNumberOfRows());
    assertEquals(3, dataTable.getNumberOfColumns());
    assertEquals(new NumberValue(4), dataTable.getRow(0).getCell(0).getValue());
    assertEquals(new NumberValue(5), dataTable.getRow(0).getCell(1).getValue());
    assertEquals(new NumberValue(6), dataTable.getRow(0).getCell(2).getValue());
    assertEquals("i1", dataTable.getColumnDescription(0).getId());
    assertEquals("1",  dataTable.getColumnDescription(0).getLabel());
    assertEquals("i2", dataTable.getColumnDescription(1).getId());
    assertEquals("2", dataTable.getColumnDescription(1).getLabel());
    assertEquals("i3", dataTable.getColumnDescription(2).getId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.