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

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


        }

        for(TableRow row : table.getRows()) {
            for(int col : indexToFormatter.keySet()) {
                TableCell cell = row.getCell(col);
                Value value = cell.getValue();
                ValueFormatter formatter = indexToFormatter.get(col);
                String formattedValue = formatter.format(value);
                cell.setFormattedValue(formattedValue);
            }
        }
View Full Code Here


        AggregationPath result = new AggregationPath();
        // The tree path is generated by looking for the values of the group-by
        // columns in the table row (in the correct order).
        for(int i = 0; i <= depth; i++) {
            String columnId = groupByColumns.get(i);
            Value curValue = row.getCell(table.getColumnIndex(columnId)).getValue();
            result.add(curValue);
        }
        return result;
    }
View Full Code Here

    private Map<String, Value> getValuesToAggregate(TableRow row, DataTable table) {
        Map<String, Value> result = Maps.newHashMap();
        // The map is generated by looking for the values of the aggregation columns
        // in the table row.
        for(String columnId : aggregateColumns) {
            Value curValue = row.getCell(table.getColumnIndex(columnId)).getValue();
            result.put(columnId, curValue);
        }
        return result;
    }
View Full Code Here

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

     */
    public static Value toValue(String content, ValueType type) {
        if(content == null) {
            return Value.getNullValueFromValueType(type);
        }
        Value value;
        switch(type) {
            case NUMBER:
                return new NumberValue(Double.parseDouble(content));
            case BOOLEAN:
                return BooleanValue.getInstance(Boolean.parseBoolean(content));
View Full Code Here

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

     * @param values A list of the values on which the scalar function is performed.
     * @return Value with the timeComponent value of the given value, or number
     *         null value if value is null.
     */
    public Value evaluate(List<Value> values) {
        Value value = values.get(0);
        ValueType valueType = value.getType();
        int component;

        // If the value is null, return a null number value.
        if(value.isNull()) {
            return NumberValue.getNullValue();
        }

        switch(timeComponent) {
            case YEAR:
View Full Code Here

     *         otherwise.
     */
    @Override
    public boolean isMatch(DataTable table, TableRow row) {
        DataTableColumnLookup lookup = new DataTableColumnLookup(table);
        Value firstValue = firstColumn.getValue(lookup, row);
        Value secondValue = secondColumn.getValue(lookup, row);
        return isOperatorMatch(firstValue, secondValue);
    }
View Full Code Here

     * @param values A list of values on which the scalar function will be performed.
     * @return Value holding the difference, in whole days, between the two given Date/DateTime
     *         values, or a null value (of type number) if one of the values is null.
     */
    public Value evaluate(List<Value> values) {
        Value firstValue = values.get(0);
        Value secondValue = values.get(1);

        // If one of the values is null, return a null number value.
        if(firstValue.isNull() || secondValue.isNull()) {
            return NumberValue.getNullValue();
        }
        Date firstDate = getDateFromValue(firstValue);
        Date secondDate = getDateFromValue(secondValue);

View Full Code Here

        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

TOP

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

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.