Package com.google.visualization.datasource.datatable

Examples of com.google.visualization.datasource.datatable.TableCell


        sb.append("]"); // columns.

        if(includeValues) {
            sb.append(",\"rows\":[");
            List<TableCell> cells;
            TableCell cell;
            ColumnDescription columnDescription;

            List<TableRow> rows = dataTable.getRows();
            for(int rowId = 0; rowId < rows.size(); rowId++) {
                TableRow tableRow = rows.get(rowId);
View Full Code Here


        assertEquals("", r.renderDataTable(dataTable, true, false));
        assertEquals("", r.renderDataTable(dataTable, true, true));
    }

    public void testAppendCellJson() {
        TableCell dateCell = new TableCell(new DateValue(2009, 1, 12));
        TableCell timeofdayCell = new TableCell(new TimeOfDayValue(12, 13, 14, 15));
        TableCell datetimeCell = new TableCell(new DateTimeValue(2009, 1, 12, 12, 13, 14, 15));
        TableCell booleanCell = new TableCell(true);
        TableCell numberCell = new TableCell(12.3);
        TableCell textCell = new TableCell("aba");

        JsonRenderer r = new JsonpRenderer();

        assertEquals("{\"v\":new Date(2009,1,12)}",
                r.appendCellJson(dateCell, new StringBuilder(),
                        true, false).toString());
        assertEquals("{\"v\":[12,13,14,15]}",
                r.appendCellJson(timeofdayCell, new StringBuilder(),
                        true, false).toString());
        assertEquals("{\"v\":new Date(2009,1,12,12,13,14)}", //no milliseconds passed
                r.appendCellJson(datetimeCell, new StringBuilder(),
                        true, false).toString());
        assertEquals("{\"v\":true}",
                r.appendCellJson(booleanCell, new StringBuilder(),
                        true, false).toString());
        assertEquals("{\"v\":12.3}",
                r.appendCellJson(numberCell, new StringBuilder(),
                        true, false).toString());
        assertEquals("{\"v\":\"aba\"}",
                r.appendCellJson(textCell, new StringBuilder(),
                        true, false).toString());

        // No formatting still stays the same when there is no formatted value
        assertEquals("{\"v\":12.3}",
                r.appendCellJson(numberCell, new StringBuilder(),
                        false, false).toString());


        dateCell = new TableCell(new DateValue(2009, 1, 12), "2009-2-12");

        // With formatting
        assertEquals("{\"v\":new Date(2009,1,12),\"f\":\"2009-2-12\"}",
                r.appendCellJson(dateCell, new StringBuilder(),
                        true, false).toString());

        // Without formatting
        assertEquals("{\"v\":new Date(2009,1,12)}",
                r.appendCellJson(dateCell, new StringBuilder(),
                        false, false).toString());

        TableCell nullCell = new TableCell(Value.getNullValueFromValueType(ValueType.NUMBER));

        // Null value
        assertEquals("",
                r.appendCellJson(nullCell, new StringBuilder(),
                        true, false).toString());
View Full Code Here

        testData.addColumn(c2);

        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(""));
        row.addCell(new TableCell(NumberValue.getNullValue()));
        row.addCell(new TableCell(true));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new TextValue("bbb"), "bbb"));
        row.addCell(new TableCell(333));
        row.addCell(new TableCell(true));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell("d'dd"));
        row.addCell(new TableCell(222));
        row.addCell(new TableCell(false));
        rows.add(row);

        testData.addRows(rows);

        JsonRenderer r = new JsonpRenderer();
View Full Code Here

        testData.addColumn(c2);

        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)));
        row.addCell(new TableCell(NumberValue.getNullValue()));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 3), "1/3/2011"));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 3, 3, 15, 0, 0), "1/1/2011 03:15:00"));
        row.addCell(new TableCell(333));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell(new DateValue(2011, 1, 4)));
        row.addCell(new TableCell(new DateTimeValue(2011, 1, 4, 0, 0, 0, 0)));
        row.addCell(new TableCell(222));
        rows.add(row);

        testData.addRows(rows);

        JsonpRenderer r = new JsonpRenderer();
View Full Code Here

        testData.addColumn(c1);

        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

        testData.addColumn(c1);

        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()));
        rows.add(row);
        row.setCustomProperty("sensi", "puff");

        testData.addRows(rows);
View Full Code Here

        dataTable.addColumn(c2);

        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(""));
        row.addCell(new TableCell(111));
        row.addCell(new TableCell(true));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell((new TextValue("bbb")), "bbb"));
        row.addCell(new TableCell(333));
        row.addCell(new TableCell(true));
        rows.add(row);

        row = new TableRow();
        row.addCell(new TableCell("ddd"));
        row.addCell(new TableCell(222));
        row.addCell(new TableCell(false));
        rows.add(row);
        dataTable.addRows(rows);

        return dataTable;
    }
View Full Code Here

* @author Yonatan B.Y.
*/
public class CompoundFilterTest extends TestCase {
    public void testAndFilter() {
        TableRow trueRow = new TableRow();
        trueRow.addCell(new TableCell("a"));
        trueRow.addCell(new TableCell(123));
        trueRow.addCell(new TableCell("a"));
        TableRow falseRow = new TableRow();
        falseRow.addCell(new TableCell("a"));
        falseRow.addCell(new TableCell(123));
        falseRow.addCell(new TableCell("b"));

        DataTable table = new DataTable();
        table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
        table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
        table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));
View Full Code Here

        assertFalse(compoundFilter.isMatch(table, falseRow));
    }

    public void testOrFilter() {
        TableRow falseRow = new TableRow();
        falseRow.addCell(new TableCell("a"));
        falseRow.addCell(new TableCell(123));
        falseRow.addCell(new TableCell("a"));
        TableRow trueRow = new TableRow();
        trueRow.addCell(new TableCell("a"));
        trueRow.addCell(new TableCell(123));
        trueRow.addCell(new TableCell("b"));

        DataTable table = new DataTable();
        table.addColumn(new ColumnDescription("c1", ValueType.TEXT, "c1"));
        table.addColumn(new ColumnDescription("c2", ValueType.TEXT, "c2"));
        table.addColumn(new ColumnDescription("c3", ValueType.TEXT, "c3"));
View Full Code Here

        table.addColumn(new ColumnDescription("numberCol", ValueType.NUMBER, "numberCol"));
        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 =
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.datatable.TableCell

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.