@Override public Value convertPrecision(long precision, boolean force) { if (value.length <= precision) { return this; } int len = MathUtils.convertLongToInt(precision); byte[] buff = new byte[len]; System.arraycopy(value, 0, buff, 0, len); return get(buff); }
/** * Get or create a bytes value for the given byte array. * Do not clone the date. * * @param b the byte array * @return the value */ public static ValueBytes getNoCopy(byte[] b) { if (b.length == 0) { return EMPTY; } ValueBytes obj = new ValueBytes(b); if (b.length > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueBytes) Value.cache(obj); }
@Override public Object getObject() { return getBytes(); }
/** * Get or create a bytes value for the given byte array. * Clone the data. * * @param b the byte array * @return the value */ public static ValueBytes get(byte[] b) { if (b.length == 0) { return EMPTY; } b = Utils.cloneByteArray(b); return getNoCopy(b); }
@Override public String getSQL() { return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'"; }
byte[] buff = rs.getBytes(columnIndex); v = buff == null ? (Value) ValueNull.INSTANCE : ValueBytes.getNoCopy(buff); break;
@Override public byte[] getBytes() { return Utils.cloneByteArray(getBytesNoCopy()); }
/** * 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 updateBytes(int columnIndex, byte[] x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateBytes(" + columnIndex + ", x);"); } update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueBytes.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
case JAVA_OBJECT: case BLOB: return ValueBytes.getNoCopy(getBytesNoCopy()); case UUID: return ValueBytes.getNoCopy(getBytes()); case BYTE: return ValueBytes.getNoCopy(new byte[]{getByte()}); case SHORT: { int x = getShort(); return ValueBytes.getNoCopy(new byte[]{ (byte) (x >> 8), (byte) x return ValueBytes.getNoCopy(new byte[]{ (byte) (x >> 24), (byte) (x >> 16), return ValueBytes.getNoCopy(new byte[]{ (byte) (x >> 56), (byte) (x >> 48), return ValueTimestamp.parse(s.trim()); case BYTES: return ValueBytes.getNoCopy( StringUtils.convertHexToBytes(s.trim())); case JAVA_OBJECT:
/** * 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 updateBytes(String columnLabel, byte[] x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateBytes(" + quote(columnLabel) + ", x);"); } update(columnLabel, x == null ? (Value) ValueNull.INSTANCE : ValueBytes.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Sets the value of a parameter as a byte array. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setBytes(int parameterIndex, byte[] x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setBytes(" + parameterIndex + ", " + quoteBytes(x) + ");"); } Value v = x == null ? (Value) ValueNull.INSTANCE : ValueBytes.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
byte[] buffer = StringUtils .convertHexToBytes(currentValue.getString()); r = ValueExpression.get(ValueBytes.getNoCopy(buffer)); } else if (equalsToken("E", name)) { String text = currentValue.getString();
return ValueDouble.get(((Double) x).doubleValue()); } else if (x instanceof byte[]) { return ValueBytes.get((byte[]) x); } else if (x instanceof Date) { return ValueDate.get((Date) x);