org.h2.value.Value.convertTo()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.h2.value.Value.convertTo()方法的一些代码示例,展示了Value.convertTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Value.convertTo()方法的具体详情如下:
包路径:org.h2.value.Value
类名称:Value
方法名:convertTo

Value.convertTo介绍

[英]Compare a value to the specified type.
[中]将值与指定的类型进行比较。

代码示例

代码示例来源:origin: com.h2database/h2

/**
 * Compare a value to the specified type.
 *
 * @param targetType the type of the returned value
 * @return the converted value
 */
public Value convertTo(int targetType) {
  // Use -1 to indicate "default behaviour" where value conversion should not
  // depend on any datatype precision.
  return convertTo(targetType, -1, null);
}

代码示例来源:origin: com.h2database/h2

/**
 * Convert value to ENUM value
 * @param enumerators allowed values for the ENUM to which the value is converted
 * @return value represented as ENUM
 */
public Value convertToEnum(String[] enumerators) {
  // Use -1 to indicate "default behaviour" where value conversion should not
  // depend on any datatype precision.
  return convertTo(ENUM, -1, null, null, enumerators);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value convertTo(int targetType, int precision, Mode mode, Object column, String[] enumerators) {
  if (targetType == Value.JAVA_OBJECT) {
    return this;
  }
  return super.convertTo(targetType, precision, mode, column, null);
}

代码示例来源:origin: com.h2database/h2

/**
 * Compare a value to the specified type.
 *
 * @param targetType the type of the returned value
 * @param precision the precision of the column to convert this value to.
 *        The special constant <code>-1</code> is used to indicate that
 *        the precision plays no role when converting the value
 * @param mode the mode
 * @return the converted value
 */
public final Value convertTo(int targetType, int precision, Mode mode) {
  return convertTo(targetType, precision, mode, null, null);
}

代码示例来源:origin: com.h2database/h2

private Value convertResult(Value v) {
  return v.convertTo(dataType);
}

代码示例来源:origin: com.h2database/h2

public Time getTime() {
  return ((ValueTime) convertTo(Value.TIME)).getTime();
}

代码示例来源:origin: com.h2database/h2

@Override
public Value add(final Value v) {
  final Value iv = v.convertTo(Value.INT);
  return convertTo(Value.INT).add(iv);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value multiply(final Value v) {
  final Value iv = v.convertTo(Value.INT);
  return convertTo(Value.INT).multiply(iv);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value getValue(Session session) {
  Value v = condition.getValue(session);
  if (v == ValueNull.INSTANCE) {
    return v;
  }
  return v.convertTo(Value.BOOLEAN).negate();
}

代码示例来源:origin: com.h2database/h2

@Override
public Value divide(final Value v) {
  final Value iv = v.convertTo(Value.INT);
  return convertTo(Value.INT).divide(iv);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value add(Value v) {
  ValueTime t = (ValueTime) v.convertTo(Value.TIME);
  return ValueTime.fromNanos(nanos + t.getNanos());
}

代码示例来源:origin: com.h2database/h2

@Override
Value getValue(Database database, int dataType, boolean distinct) {
  if (distinct) {
    throw DbException.throwInternalError();
  }
  Value v = ValueLong.get(count);
  return v == null ? ValueNull.INSTANCE : v.convertTo(dataType);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value modulus(final Value v) {
  final Value iv = v.convertTo(Value.INT);
  return convertTo(Value.INT).modulus(iv);
}

代码示例来源:origin: com.h2database/h2

@Override
  public Value subtract(final Value v) {
    final Value iv = v.convertTo(Value.INT);
    return convertTo(Value.INT).subtract(iv);
  }
}

代码示例来源:origin: com.h2database/h2

@Override
Value getValue(Database database, int dataType, boolean distinct) {
  if (distinct) {
    if (distinctValues != null) {
      count = distinctValues.size();
    } else {
      count = 0;
    }
  }
  Value v = ValueLong.get(count);
  return v.convertTo(dataType);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value subtract(Value v) {
  ValueTime t = (ValueTime) v.convertTo(Value.TIME);
  return ValueTime.fromNanos(nanos - t.getNanos());
}

代码示例来源:origin: com.h2database/h2

@Override
public Value subtract(Value v) {
  ValueTimestamp t = (ValueTimestamp) v.convertTo(Value.TIMESTAMP);
  long d1 = DateTimeUtils.absoluteDayFromDateValue(dateValue);
  long d2 = DateTimeUtils.absoluteDayFromDateValue(t.dateValue);
  return DateTimeUtils.normalizeTimestamp(d1 - d2, timeNanos - t.timeNanos);
}

代码示例来源:origin: com.h2database/h2

@Override
public Value add(Value v) {
  ValueTimestamp t = (ValueTimestamp) v.convertTo(Value.TIMESTAMP);
  long d1 = DateTimeUtils.absoluteDayFromDateValue(dateValue);
  long d2 = DateTimeUtils.absoluteDayFromDateValue(t.dateValue);
  return DateTimeUtils.normalizeTimestamp(d1 + d2, timeNanos + t.timeNanos);
}

代码示例来源:origin: com.h2database/h2

private static Value divide(Value a, long by) {
  if (by == 0) {
    return ValueNull.INSTANCE;
  }
  int type = Value.getHigherOrder(a.getType(), Value.LONG);
  Value b = ValueLong.get(by).convertTo(type);
  a = a.convertTo(type).divide(b);
  return a;
}

代码示例来源:origin: com.h2database/h2

private SpatialKey getKey(SearchRow row) {
  Value v = row.getValue(columnIds[0]);
  if (v == ValueNull.INSTANCE) {
    return new SpatialKey(row.getKey());
  }
  Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy();
  Envelope env = g.getEnvelopeInternal();
  return new SpatialKey(row.getKey(),
      (float) env.getMinX(), (float) env.getMaxX(),
      (float) env.getMinY(), (float) env.getMaxY());
}

相关文章