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

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


                        + "14,2000-02-01 01:10:31.004\nddd,222.0,false,1997-06-05,12:15:15. 14,3100-02-02 15:15:01",
                testData.toString());
    }

    public void testGetCellAndGetValue() {
        assertEquals(new TextValue("ccc"), testData.getValue(1, 0));
        TableCell cell = testData.getCell(1, 0);
        assertEquals("$ccc", cell.getFormattedValue());
    }
View Full Code Here


      default:
        String colValue = rs.getString(column);
        if (colValue == null) {
          value = TextValue.getNullValue();
        } else {
          value = new TextValue(rs.getString(column));
        }
        break;
    }
    // Handle null values.
    if (rs.wasNull()) {
View Full Code Here

        assertTrue(filter instanceof ColumnValueFilter);
        ColumnValueFilter f = (ColumnValueFilter) filter;
        assertEquals("selEct", f.getColumn().getId());
        Value val = f.getValue();
        assertTrue(val instanceof TextValue);
        TextValue v = (TextValue) val;
        assertEquals("baba", v.toString());
        assertEquals(ComparisonFilter.Operator.EQ, f.getOperator());
    }
View Full Code Here

                case BOOLEAN:
                    value = parseBoolean(val);
                    break;
                case TEXT:
                    // do nothing
                    value = new TextValue(val);
                    break;
            }
        }
        catch(ParseException pe) {
            value = Value.getNullValueFromValueType(type);
View Full Code Here

        assertTrue(filter instanceof ColumnValueFilter);
        ColumnValueFilter f = (ColumnValueFilter) filter;
        assertEquals("MiN", f.getColumn().getId());
        Value val = f.getValue();
        assertTrue(val instanceof TextValue);
        TextValue v = (TextValue) val;
        assertEquals("baba", v.toString());
        assertEquals(ComparisonFilter.Operator.NE, f.getOperator());
    }
View Full Code Here

        assertTrue(filter instanceof ColumnValueFilter);
        ColumnValueFilter f = (ColumnValueFilter) filter;
        assertEquals("count", f.getColumn().getId());
        Value val = f.getValue();
        assertTrue(val instanceof TextValue);
        TextValue v = (TextValue) val;
        assertEquals("select", v.toString());
        assertEquals(ComparisonFilter.Operator.GT, f.getOperator());
        assertEquals(true, f.isComparisonOrderReversed());
    }
View Full Code Here

        assertEquals(ComparisonFilter.Operator.NE, filters[1].getOperator());
        assertEquals(ComparisonFilter.Operator.NE, filters[2].getOperator());
        assertEquals(ComparisonFilter.Operator.NE, filters[3].getOperator());
        assertEquals(ComparisonFilter.Operator.NE, filters[4].getOperator());

        assertEquals(new TextValue("2008-06-01"), filters[0].getValue());
        assertEquals(new NumberValue(47), filters[1].getValue());
        assertEquals(new NumberValue(6), filters[2].getValue());
        assertEquals(new NumberValue(8), filters[3].getValue());
        assertEquals(new NumberValue(2), filters[4].getValue());
View Full Code Here

        // Null TableDescription.
        reader = new StringReader("\n\n\n1,2,3\n\n4,5,6\n\n\n\n\n");
        dataTable = CsvDataSourceHelper.read(reader, null, false);
        assertEquals(2, dataTable.getNumberOfRows());
        assertEquals(3, dataTable.getNumberOfColumns());
        assertEquals(new TextValue("1"), dataTable.getRow(0).getCell(0).getValue());
        assertEquals(new TextValue("2"), dataTable.getRow(0).getCell(1).getValue());
        assertEquals(new TextValue("3"), dataTable.getRow(0).getCell(2).getValue());
        assertEquals(new TextValue("4"), dataTable.getRow(1).getCell(0).getValue());
        assertEquals(new TextValue("5"), dataTable.getRow(1).getCell(1).getValue());
        assertEquals(new TextValue("6"), dataTable.getRow(1).getCell(2).getValue());

        // Different column numbers.
        boolean catched = false;
        try {
            reader = new StringReader("1,2\na, b, c");
            dataTable = CsvDataSourceHelper.read(reader, null, false);
        }
        catch(CsvDataSourceException e) {
            catched = true;
            assertEquals(ReasonType.INTERNAL_ERROR, e.getReasonType());
            assertEquals(
                    "Wrong number of columns in the data.",
                    e.getMessageToUser());
        }
        assertTrue(catched);

        // Working example with a table description filled only with types.
        reader = new StringReader("1,a,true\n4,x13a,false\n1400,4,true");
        List<ColumnDescription> 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(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());
        assertEquals("a", dataTable.getColumnDescription(1).getLabel());
        assertEquals("i3", dataTable.getColumnDescription(2).getId());
        assertEquals("2004-03-01", dataTable.getColumnDescription(2).getLabel());

        // Bad table description for that data.
        catched = false;
        try {
            reader = new StringReader("true\nfalse\nfalse");
            columnDescriptions = Lists.newArrayList();
            dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
        }
        catch(CsvDataSourceException e) {
            catched = true;
            assertEquals(ReasonType.INTERNAL_ERROR, e.getReasonType());
            assertEquals(
                    "Wrong number of columns in the data.",
                    e.getMessageToUser());
        }
        assertTrue(catched);

        // Working example with a null table description.
        reader = new StringReader("true,false\ntrue,false\ntrue,false\nfalse,false");
        columnDescriptions = null;
        dataTable = CsvDataSourceHelper.read(reader, columnDescriptions, false);
        assertEquals(4, dataTable.getNumberOfRows());
        assertEquals(2, dataTable.getNumberOfColumns());
        assertEquals(new TextValue("true"), dataTable.getRow(0).getCell(0).getValue());
        assertEquals(new TextValue("false"), dataTable.getRow(0).getCell(1).getValue());
        assertEquals(new TextValue("true"), dataTable.getRow(1).getCell(0).getValue());
        assertEquals(new TextValue("false"), dataTable.getRow(1).getCell(1).getValue());
        assertEquals(new TextValue("true"), dataTable.getRow(2).getCell(0).getValue());
        assertEquals(new TextValue("false"), dataTable.getRow(2).getCell(1).getValue());
        assertEquals(new TextValue("false"), dataTable.getRow(3).getCell(0).getValue());
        assertEquals(new TextValue("false"), dataTable.getRow(3).getCell(1).getValue());

        // Working example with a table description filled with types.
        reader = new StringReader("true,false\ntrue,false\ntrue,false\nfalse,false");
        columnDescriptions = Lists.newArrayList();
        columnDescriptions.add(new ColumnDescription("1", ValueType.BOOLEAN, "123"));
View Full Code Here

        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());
        assertEquals("a", dataTable.getColumnDescription(1).getLabel());
View Full Code Here

        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"),
                new TextValue("b"), ComparisonFilter.Operator.LT, true);
        assertFalse(filter.isMatch(table, row));
    }
View Full Code Here

TOP

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

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.