/** * 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); }
/** * 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); }
@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); }
/** * 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); }
private Value convertResult(Value v) { return v.convertTo(dataType); }
public Time getTime() { return ((ValueTime) convertTo(Value.TIME)).getTime(); }
@Override public Value add(final Value v) { final Value iv = v.convertTo(Value.INT); return convertTo(Value.INT).add(iv); }
@Override public Value multiply(final Value v) { final Value iv = v.convertTo(Value.INT); return convertTo(Value.INT).multiply(iv); }
@Override public Value getValue(Session session) { Value v = condition.getValue(session); if (v == ValueNull.INSTANCE) { return v; } return v.convertTo(Value.BOOLEAN).negate(); }
@Override public Value divide(final Value v) { final Value iv = v.convertTo(Value.INT); return convertTo(Value.INT).divide(iv); }
@Override public Value add(Value v) { ValueTime t = (ValueTime) v.convertTo(Value.TIME); return ValueTime.fromNanos(nanos + t.getNanos()); }
@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); }
@Override public Value modulus(final Value v) { final Value iv = v.convertTo(Value.INT); return convertTo(Value.INT).modulus(iv); }
@Override public Value subtract(final Value v) { final Value iv = v.convertTo(Value.INT); return convertTo(Value.INT).subtract(iv); } }
@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); }
@Override public Value subtract(Value v) { ValueTime t = (ValueTime) v.convertTo(Value.TIME); return ValueTime.fromNanos(nanos - t.getNanos()); }
@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); }
@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); }
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; }
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()); }