@Override public Value multiply(Value v) { ValueShort other = (ValueShort) v; return checkRange(value * other.value); }
@Override public String getSQL() { return getString(); }
private static ValueShort checkRange(int x) { if (x < Short.MIN_VALUE || x > Short.MAX_VALUE) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Integer.toString(x)); } return ValueShort.get((short) x); }
/** * Get or create a short value for the given short. * * @param i the short * @return the value */ public static ValueShort get(short i) { return (ValueShort) Value.cache(new ValueShort(i)); }
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setShort(int parameterIndex, short x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setShort(" + parameterIndex + ", (short) " + x + ");"); } setParameter(parameterIndex, ValueShort.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateShort(int columnIndex, short x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateShort(" + columnIndex + ", (short) " + x + ");"); } update(columnIndex, ValueShort.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value add(Value v) { ValueShort other = (ValueShort) v; return checkRange(value + other.value); }
/** * Updates a column in the current or insert row. * * @param columnLabel the column label * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateShort(String columnLabel, short x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateShort(" + quote(columnLabel) + ", (short) " + x + ");"); } update(columnLabel, ValueShort.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value subtract(Value v) { ValueShort other = (ValueShort) v; return checkRange(value - other.value); }
short value = rs.getShort(columnIndex); v = rs.wasNull() ? (Value) ValueNull.INSTANCE : ValueShort.get(value); break;
@Override public Value negate() { return checkRange(-(int) value); }
return ValueByte.get(((Byte) x).byteValue()); } else if (x instanceof Short) { return ValueShort.get(((Short) x).shortValue()); } else if (x instanceof Float) { return ValueFloat.get(((Float) x).floatValue());
switch (getType()) { case BOOLEAN: return ValueShort.get(getBoolean().booleanValue() ? (short) 1 : (short) 0); case BYTE: return ValueShort.get(getByte()); case INT: return ValueShort.get(convertToShort(getInt())); case LONG: return ValueShort.get(convertToShort(getLong())); case DECIMAL: return ValueShort.get(convertToShort(convertToLong(getBigDecimal()))); case DOUBLE: return ValueShort.get(convertToShort(convertToLong(getDouble()))); case FLOAT: return ValueShort.get(convertToShort(convertToLong(getFloat()))); case BYTES: return ValueShort.get((short) Integer.parseInt(getString(), 16)); return ValueByte.get(Byte.parseByte(s.trim())); case SHORT: return ValueShort.get(Short.parseShort(s.trim())); case INT: return ValueInt.get(Integer.parseInt(s.trim()));