/** * 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 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 String getSQL() { return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'"; }
@Override public Object getObject() { return getBytes(); }
@Override public byte[] getBytes() { return Utils.cloneByteArray(getBytesNoCopy()); }
public byte[] getBytes() { return ((ValueBytes) convertTo(Value.BYTES)).getBytes(); }
v = buff == null ? (Value) ValueNull.INSTANCE : ValueBytes.getNoCopy(buff); break;
/** * 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); } }
public byte[] getBytesNoCopy() { return ((ValueBytes) convertTo(Value.BYTES)).getBytesNoCopy(); }
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 }); .getNoCopy(new byte[] { (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }); return ValueBytes.getNoCopy(new byte[] { (byte) (x >> 56), (byte) (x >> 48), (byte) (x >> 40), (byte) (x >> 32), (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }); return ValueTimestamp.parse(s.trim()); case BYTES: return ValueBytes.getNoCopy(StringUtils.convertHexToBytes(s.trim())); case JAVA_OBJECT: return ValueJavaObject.getNoCopy(null, StringUtils.convertHexToBytes(s.trim()));
/** * 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); } }
buff.get(b, 0, len); if (type == Value.BYTES) { return ValueBytes.getNoCopy(b); } else {
/** * 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); } }
break; case SECURE_RAND: result = ValueBytes.getNoCopy(MathUtils.secureRandomBytes(v0.getInt())); break; case EXPAND: result = ValueBytes.getNoCopy(CompressTool.getInstance().expand(v0.getBytesNoCopy())); break; case ZERO: break; case STRINGTOUTF8: result = ValueBytes.getNoCopy(v0.getString().getBytes(Constants.UTF8)); break; case UTF8TOSTRING:
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);
result = ValueBytes.getNoCopy(getHash(v0.getString(), v1.getBytesNoCopy(), v2.getInt())); break; case ENCRYPT: result = ValueBytes.getNoCopy(encrypt(v0.getString(), v1.getBytesNoCopy(), v2.getBytesNoCopy())); break; case DECRYPT: result = ValueBytes.getNoCopy(decrypt(v0.getString(), v1.getBytesNoCopy(), v2.getBytesNoCopy())); break; case COMPRESS: { algorithm = v1.getString(); result = ValueBytes.getNoCopy(CompressTool.getInstance().compress(v0.getBytesNoCopy(), algorithm)); break;
read(); byte[] buffer = StringUtils.convertHexToBytes(currentValue.getString()); r = ValueExpression.get(ValueBytes.getNoCopy(buffer)); } else if (equalsToken("E", name)) { String text = currentValue.getString();
return ValueNull.INSTANCE; case Value.BYTES: return ValueBytes.getNoCopy(readBytes()); case Value.JAVA_OBJECT: return ValueJavaObject.getNoCopy(null, readBytes());