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

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


     * @param isLastColumn      Is this the last column in the row.
     * @return The input string builder.
     */
    protected StringBuilder appendCellJson(TableCell cell,
                                           StringBuilder sb, boolean includeFormatting, boolean isLastColumn) {
        Value value = cell.getValue();
        ValueType type = cell.getType();
        StringBuilder valueJson = new StringBuilder();
        GregorianCalendar calendar;
        String escapedFormattedString = "";
        boolean isJsonNull = false;

        // Prepare a Json string representing the current value.
        DateValue dateValue;
        TimeOfDayValue timeOfDayValue;
        if((value == null) || (value.isNull())) {
            valueJson.append("null");
            isJsonNull = true;
        }
        else {
            switch(type) {
                case BOOLEAN:
                    valueJson.append(((BooleanValue) value).getValue());
                    break;
                case DATE:
                    valueJson.append("Date(");
                    dateValue = (DateValue) value;
                    valueJson.append(dateValue.getYear()).append(",");
                    valueJson.append(dateValue.getMonth()).append(",");
                    valueJson.append(dateValue.getDayOfMonth());
                    valueJson.append(")");
                    this.appendDate(valueJson);
                    break;
                case NUMBER:
                    valueJson.append(((NumberValue) value).getValue());
                    break;
                case TEXT:
                    valueJson.append("\"");
                    valueJson.append(EscapeUtil.jsonEscape(value.toString()));
                    valueJson.append("\"");
                    break;
                case TIMEOFDAY:
                    valueJson.append("[");
                    timeOfDayValue = (TimeOfDayValue) value;
                    valueJson.append(timeOfDayValue.getHours()).append(",");
                    valueJson.append(timeOfDayValue.getMinutes()).append(",");
                    valueJson.append(timeOfDayValue.getSeconds()).append(",");
                    valueJson.append(timeOfDayValue.getMilliseconds());
                    valueJson.append("]");
                    break;
                case DATETIME:
                    calendar = ((DateTimeValue) value).getCalendar();
                    valueJson.append("Date(");
                    valueJson.append(calendar.get(GregorianCalendar.YEAR)).append(",");
                    valueJson.append(calendar.get(GregorianCalendar.MONTH)).append(",");
                    valueJson.append(calendar.get(GregorianCalendar.DAY_OF_MONTH));
                    valueJson.append(",");
                    valueJson.append(calendar.get(GregorianCalendar.HOUR_OF_DAY));
                    valueJson.append(",");
                    valueJson.append(calendar.get(GregorianCalendar.MINUTE)).append(",");
                    valueJson.append(calendar.get(GregorianCalendar.SECOND));
                    valueJson.append(")");
                    this.appendDate(valueJson);
                    break;
                default:
                    throw new IllegalArgumentException("Illegal value Type " + type);
            }
        }

        // Prepare an escaped string representing the current formatted value.
        String formattedValue = cell.getFormattedValue();
        if((value != null) && !value.isNull() && (formattedValue != null)) {
            escapedFormattedString = EscapeUtil.jsonEscape(formattedValue);
            // Check for a value of type TEXT if the formatted value equals
            // its ordinary toString.
            if((type == ValueType.TEXT) && value.toString().equals(formattedValue)) {
                escapedFormattedString = "";
            }
        }

        // Add a Json for this cell. And,
View Full Code Here


     * @return The table cell.
     * @throws SQLException Thrown when the connection to the database failed.
     */
    private static TableCell buildTableCell(ResultSet rs, ValueType valueType,
                                            int column) throws SQLException {
        Value value = null;

        // SQL indexes are 1- based.
        column = column + 1;

        switch(valueType) {
View Full Code Here

                        valueFormatter = defaultFormatters.get(valueType);
                    }
                    else {
                        valueFormatter = ValueFormatter.createFromPattern(valueType, pattern, locale);
                    }
                    Value value = valueFormatter.parse(string);

                    tableRow.addCell(value);
                }
                try {
                    dataTable.addRow(tableRow);
View Full Code Here

        for (final DateTime rowTime : reportTimes) {
            // create the row
            final TableRow row = new TableRow();

            // add the date to the first cell
            final Value dateTimeValue;
            switch (dateTimeColumnType) {
                case DATE: {
                    dateTimeValue = new DateValue(rowTime.getYear(), rowTime.getMonthOfYear()-1, rowTime.getDayOfMonth());
                    break;
                }
View Full Code Here

          if (pattern == null || pattern.equals("")) {
            valueFormatter = defaultFormatters.get(valueType);
          } else {
            valueFormatter = ValueFormatter.createFromPattern(valueType, pattern, locale);
          }
          Value value = valueFormatter.parse(string);
         
          tableRow.addCell(value);
        }
        try {
          dataTable.addRow(tableRow);
View Full Code Here

   *
   * @return The input string builder.
   */
  public static StringBuilder appendCellJson(TableCell cell,
      StringBuilder sb, boolean includeFormatting, boolean isLastColumn) {
    Value value = cell.getValue();
    ValueType type = cell.getType();
    StringBuilder valueJson = new StringBuilder();
    GregorianCalendar calendar;
    String escapedFormattedString = "";
    boolean isJsonNull = false;

    // Prepare a Json string representing the current value.
    DateValue dateValue;
    TimeOfDayValue timeOfDayValue;
    if ((value == null) || (value.isNull())) {
      valueJson.append("null");
      isJsonNull = true;
    } else {
      switch (type) {
        case BOOLEAN:
          valueJson.append(((BooleanValue) value).getValue());
          break;
        case DATE:
          valueJson.append("new Date(");
          dateValue = (DateValue) value;
          valueJson.append(dateValue.getYear()).append(",");
          valueJson.append(dateValue.getMonth()).append(",");
          valueJson.append(dateValue.getDayOfMonth());
          valueJson.append(")");
          break;
        case NUMBER:
          valueJson.append(((NumberValue) value).getValue());
          break;
        case TEXT:
          valueJson.append("'");
          valueJson.append(EscapeUtil.jsonEscape(value.toString()));
          valueJson.append("'");
          break;
        case TIMEOFDAY:
          valueJson.append("[");
          timeOfDayValue = (TimeOfDayValue) value;
          valueJson.append(timeOfDayValue.getHours()).append(",");
          valueJson.append(timeOfDayValue.getMinutes()).append(",");
          valueJson.append(timeOfDayValue.getSeconds()).append(",");
          valueJson.append(timeOfDayValue.getMilliseconds());
          valueJson.append("]");
          break;
        case DATETIME:
          calendar = ((DateTimeValue) value).getCalendar();
          valueJson.append("new Date(");
          valueJson.append(calendar.get(GregorianCalendar.YEAR)).append(",");
          valueJson.append(calendar.get(GregorianCalendar.MONTH)).append(",");
          valueJson.append(calendar.get(GregorianCalendar.DAY_OF_MONTH));
          valueJson.append(",");
          valueJson.append(calendar.get(GregorianCalendar.HOUR_OF_DAY));
          valueJson.append(",");
          valueJson.append(calendar.get(GregorianCalendar.MINUTE)).append(",");
          valueJson.append(calendar.get(GregorianCalendar.SECOND));
          valueJson.append(")");
          break;
        default:
          throw new IllegalArgumentException("Illegal value Type " + type);
      }
    }

    // Prepare an escaped string representing the current formatted value.
    String formattedValue = cell.getFormattedValue();
    if ((value != null) && !value.isNull() && (formattedValue != null)) {
      escapedFormattedString = EscapeUtil.jsonEscape(formattedValue);
      // Check for a value of type TEXT if the formatted value equals
      // its ordinary toString.
      if ((type == ValueType.TEXT) && value.toString().equals(formattedValue)) {
        escapedFormattedString = "";
      }
    }

    // Add a Json for this cell. And,
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

   *     constant value; false otherwise.
   */
  @Override
  public boolean isMatch(DataTable table, TableRow row) {
    DataTableColumnLookup lookup = new DataTableColumnLookup(table);
    Value columnValue = column.getValue(lookup, row);
    return isComparisonOrderReversed ? isOperatorMatch(value, columnValue) :
        isOperatorMatch(columnValue, value);
  }
View Full Code Here

    }

    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

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.