@Override public Value readValue(ByteBuffer buff) { return ValueByte.get(buff.get()); }
@Override public Value subtract(Value v) { ValueByte other = (ValueByte) v; return checkRange(value - other.value); }
@Override public String getSQL() { return getString(); }
/** * Get or create byte value for the given byte. * * @param i the byte * @return the value */ public static ValueByte get(byte i) { return (ValueByte) Value.cache(new ValueByte(i)); }
public byte getByte() { return ((ValueByte) convertTo(Value.BYTE)).getByte(); }
private static ValueByte checkRange(int x) { if (x < Byte.MIN_VALUE || x > Byte.MAX_VALUE) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Integer.toString(x)); } return ValueByte.get((byte) x); }
@Override public Value multiply(Value v) { ValueByte other = (ValueByte) v; return checkRange(value * other.value); }
/** * 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 updateByte(int columnIndex, byte x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateByte(" + columnIndex + ", " + x + ");"); } update(columnIndex, ValueByte.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value add(Value v) { ValueByte other = (ValueByte) 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 updateByte(String columnLabel, byte x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateByte(" + columnLabel + ", " + x + ");"); } update(columnLabel, ValueByte.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value negate() { return checkRange(-(int) value); }
/** * 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 setByte(int parameterIndex, byte x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setByte(" + parameterIndex + ", " + x + ");"); } setParameter(parameterIndex, ValueByte.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : ValueByte.get(value); break;
return ValueBoolean.get(((Boolean) x).booleanValue()); } else if (x instanceof Byte) { return ValueByte.get(((Byte) x).byteValue()); } else if (x instanceof Short) { return ValueShort.get(((Short) x).shortValue());
switch (getType()) { case BOOLEAN: return ValueByte.get(getBoolean().booleanValue() ? (byte) 1 : (byte) 0); case SHORT: return ValueByte.get(convertToByte(getShort())); case INT: return ValueByte.get(convertToByte(getInt())); case LONG: return ValueByte.get(convertToByte(getLong())); case DECIMAL: return ValueByte.get(convertToByte(convertToLong(getBigDecimal()))); case DOUBLE: return ValueByte.get(convertToByte(convertToLong(getDouble()))); case FLOAT: return ValueByte.get(convertToByte(convertToLong(getFloat()))); case BYTES: return ValueByte.get((byte) Integer.parseInt(getString(), 16)); return ValueByte.get(Byte.parseByte(s.trim())); case SHORT: return ValueShort.get(Short.parseShort(s.trim()));
return ValueBoolean.get(readBoolean()); case Value.BYTE: return ValueByte.get(readByte()); case Value.DATE: return ValueDate.fromDateValue(readLong());