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

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


  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


   * @param type The type of aggregation requested.
   *
   * @return The requested value.
   */
  public Value getValue(AggregationType type) {
    Value v;
    switch (type) {
      case AVG:
        v = (count != 0) ? new NumberValue(getAverage()) : NumberValue.getNullValue();
        break;
      case COUNT:
        v = new NumberValue(count);
        break;
      case MAX:
        v = max;
        // If there are zero rows replace with the same type null value.
        if (count == 0) {
          v = Value.getNullValueFromValueType(v.getType());
        }
        break;
      case MIN:
        v = min;
        // If there are zero rows replace with the same type null value.
        if (count == 0) {
          v = Value.getNullValueFromValueType(v.getType());
        }
        break;
      case SUM:
        v = (count != 0) ? new NumberValue(getSum()) : NumberValue.getNullValue();
        break;
View Full Code Here

  final public QueryFilter primitiveFilter() throws ParseException, InvalidQueryException {
  QueryFilter filter;
  AbstractColumn col1;
  AbstractColumn col2;
  ComparisonFilter.Operator op;
  Value val;
    if (jj_2_3(2147483647)) {
      val = literal();
      op = comparisonOperator();
      col1 = abstractColumnDescriptor();
      filter = new ColumnValueFilter(col1, val, op, true);
View Full Code Here

  }

// A literal. Corresponds to a value on the server, i.e., can be of one of the
// following types: string, number, boolean, date, timeOfDay, dateTime.
  final public Value literal() throws ParseException, InvalidQueryException {
  Value val;
  String str;
  double num;
  boolean bool;
  String dateStr;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
View Full Code Here

  ScalarFunction scalarFunction;
  String columnId;
  AbstractColumn column;
  ArrayList columns = new ArrayList();
  AbstractColumn result = null;
  Value value;
    if (jj_2_5(2)) {
      aggregationType = aggregationFunction();
      jj_consume_token(OP_LPAREN);
      columnId = columnId();
      jj_consume_token(OP_RPAREN);
View Full Code Here

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

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

   *
   * @return A corresponding {@code Value} for the given string. If parsing fails the value would
   * be a NULL_VALUE of the correct {@code ValueType}.
   */
  public Value parse(String val) {
    Value value = null;
    try {
      switch(type) {
        case DATE:
          value = parseDate(val);
          break;
View Full Code Here

   * @param values A list with the values that the scalar function is performed on them.
   *
   * @return A date value with the appropriate date.
   */
  public Value evaluate(List<Value> values) {
    Value value = values.get(0);
    Date date;
    GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));

    // If the given value is null, return a null date value.
    if (value.isNull()) {
      return DateValue.getNullValue();
    }
    DateValue dateValue;
    switch(value.getType()) {
      case DATE:
        dateValue = (DateValue) value;
        break;
      case DATETIME:
        dateValue = new DateValue((GregorianCalendar)
            (((DateTimeValue) value).getObjectToFormat()));
        break;
      case NUMBER:
        date = new Date((long) ((NumberValue) value).getValue());
        gc.setTime(date);
        dateValue = new DateValue(gc);
        break;
      default:// Should never get here.
        throw new RuntimeException("Value type was not found: " + value.getType());
    }
    return dateValue;
  }
View Full Code Here

        for (ColumnDescription description : columnDescriptions) {
          String columnId = description.getId();
          ValueType valueType = description.getType();
          Object oValue = getEntryValue(entry, columnId);
          if (oValue != null) {
            Value value = GVizTypeConverter.getValue(valueType, oValue);
            row.addCell(value);
          } else {
            row.addCell(Value.getNullValueFromValueType(valueType));
          }       
        }
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.