@Override public Value divide(Value v) { ValueByte other = (ValueByte) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL()); } return ValueByte.get((byte) (value / other.value)); }
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); }
/** * 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); } }
@Override public Value modulus(Value v) { ValueByte other = (ValueByte) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL()); } return ValueByte.get((byte) (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); } }
/** * 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); } }
byte value = rs.getByte(columnIndex); 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()));