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

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


        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

        // 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

        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

        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

        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

        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

        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

        if(values.get(0).isNull() || values.get(1).isNull()) {
            return NumberValue.getNullValue();
        }
        double sum = ((NumberValue) values.get(0)).getValue() +
                ((NumberValue) values.get(1)).getValue();
        return new NumberValue(sum);
    }
View Full Code Here

        columnDescriptions.add(new ColumnDescription("i4", ValueType.NUMBER, null));

        DataTable dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, true);
        assertEquals(2, dataTable.getNumberOfRows());
        assertEquals(4, 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(NumberValue.getNullValue(), dataTable.getRow(0).getCell(3).getValue());
        assertEquals(new NumberValue(7), dataTable.getRow(1).getCell(0).getValue());
        assertEquals(NumberValue.getNullValue(), dataTable.getRow(1).getCell(1).getValue());
        assertEquals(NumberValue.getNullValue(), dataTable.getRow(1).getCell(2).getValue());
        assertEquals(new NumberValue(10), dataTable.getRow(1).getCell(3).getValue());
        assertEquals("i1", dataTable.getColumnDescription(0).getId());
        assertEquals("1", dataTable.getColumnDescription(0).getLabel());
        assertEquals("i2", dataTable.getColumnDescription(1).getId());
        assertEquals("", dataTable.getColumnDescription(1).getLabel());
        assertEquals("i3", dataTable.getColumnDescription(2).getId());
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.