Package com.google.visualization.datasource.datatable

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


      String pattern = queryFormat.getPattern(col);
      List<Integer> indices = columnIndices.getColumnIndices(col);
      boolean allSucceeded = true;
      for (int i : indices) {
        ColumnDescription colDesc = columnDescriptions.get(i);
        ValueFormatter f = ValueFormatter.createFromPattern(colDesc.getType(), pattern, locale);
        if (f == null) {
          allSucceeded = false;
        } else {
          indexToFormatter.put(i, f);
          table.getColumnDescription(i).setPattern(pattern); // May override datasource pattern.
        }
      }
      if (!allSucceeded) {
        Warning warning = new Warning(ReasonType.ILLEGAL_FORMATTING_PATTERNS,
            "Illegal formatting pattern: " + pattern + " requested on column: " + col.getId());
        table.addWarning(warning);
      }
    }

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


            String pattern = queryFormat.getPattern(col);
            List<Integer> indices = columnIndices.getColumnIndices(col);
            boolean allSucceeded = true;
            for(int i : indices) {
                ColumnDescription colDesc = columnDescriptions.get(i);
                ValueFormatter f = ValueFormatter.createFromPattern(colDesc.getType(), pattern, locale);
                if(f == null) {
                    allSucceeded = false;
                }
                else {
                    indexToFormatter.put(i, f);
                    table.getColumnDescription(i).setPattern(pattern); // May override datasource pattern.
                }
            }
            if(!allSucceeded) {
                Warning warning = new Warning(ReasonType.ILLEGAL_FORMATTING_PATTERNS,
                        "Illegal formatting pattern: " + pattern + " requested on column: " + col.getId());
                table.addWarning(warning);
            }
        }

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

                    String string = line[i];
                    if(string != null) {
                        string = string.trim();
                    }
                    String pattern = columnDescription.getPattern();
                    ValueFormatter valueFormatter;
                    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

          String string = line[i];
          if (string != null) {
            string = string.trim();
          }
          String pattern = columnDescription.getPattern();
          ValueFormatter valueFormatter;
          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

      String pattern = queryFormat.getPattern(col);
      List<Integer> indices = columnIndices.getColumnIndices(col);
      boolean allSucceeded = true;
      for (int i : indices) {
        ColumnDescription colDesc = columnDescriptions.get(i);
        ValueFormatter f = ValueFormatter.createFromPattern(colDesc.getType(), pattern, locale);
        if (f == null) {
          allSucceeded = false;
        } else {
          indexToFormatter.put(i, f);
          table.getColumnDescription(i).setPattern(pattern); // May override datasource pattern.
        }
      }
      if (!allSucceeded) {
        Warning warning = new Warning(ReasonType.ILLEGAL_FORMATTING_PATTERNS,
            "Illegal formatting pattern: " + pattern + " requested on column: " + col.getId());
        table.addWarning(warning);
      }
    }

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

TOP

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

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.