public InputStream getInputStream() { return new ByteArrayInputStream(getBytesNoCopy()); }
@Override protected int compareSecure(Value v, CompareMode mode) { if (v instanceof ValueLob) { ValueLob v2 = (ValueLob) v; if (v == this) { return 0; } if (lobId == v2.lobId && small == null && v2.small == null) { return 0; } } if (type == Value.CLOB) { return Integer.signum(getString().compareTo(v.getString())); } byte[] v2 = v.getBytesNoCopy(); return Utils.compareNotNullSigned(getBytes(), v2); }
@Override protected int compareSecure(Value v, CompareMode mode) { Object o1 = getObject(); Object o2 = v.getObject(); boolean o1Comparable = o1 instanceof Comparable; boolean o2Comparable = o2 instanceof Comparable; if (o1Comparable && o2Comparable && Utils.haveCommonComparableSuperclass(o1.getClass(), o2.getClass())) { @SuppressWarnings("unchecked") Comparable<Object> c1 = (Comparable<Object>) o1; return c1.compareTo(o2); } // group by types if (o1.getClass() != o2.getClass()) { if (o1Comparable != o2Comparable) { return o1Comparable ? -1 : 1; } return o1.getClass().getName().compareTo(o2.getClass().getName()); } // compare hash codes int h1 = hashCode(); int h2 = v.hashCode(); if (h1 == h2) { if (o1.equals(o2)) { return 0; } return Utils.compareNotNullSigned(getBytesNoCopy(), v.getBytesNoCopy()); } return h1 > h2 ? 1 : -1; }
@Override public byte[] getBytesNoCopy() { if (type == CLOB) { // convert hex to string return super.getBytesNoCopy(); } if (small != null) { return small; } try { return IOUtils.readBytesAndClose(getInputStream(), Integer.MAX_VALUE); } catch (IOException e) { throw DbException.convertIOException(e, toString()); } }
/** * Convert an object to the default Java object for the given SQL type. For * example, LOB objects are converted to java.sql.Clob / java.sql.Blob. * * @param v the value * @return the object */ Object convertToDefaultObject(Value v) { Object o; switch (v.getType()) { case Value.CLOB: { int id = getNextTraceId(TraceObject.CLOB); o = new JdbcClob(this, v, id); break; } case Value.BLOB: { int id = getNextTraceId(TraceObject.BLOB); o = new JdbcBlob(this, v, id); break; } case Value.JAVA_OBJECT: if (SysProperties.SERIALIZE_JAVA_OBJECT) { o = Utils.deserialize(v.getBytesNoCopy()); break; } default: o = v.getObject(); } return o; }
case Value.BYTES: case Value.JAVA_OBJECT: { byte[] b = v.getBytesNoCopy(); buff.put((byte) type).putVarInt(b.length).put(b); break;
case JAVA_OBJECT: case BLOB: return ValueBytes.getNoCopy(getBytesNoCopy()); case UUID: return ValueBytes.getNoCopy(getBytes()); case BYTES: case BLOB: return ValueJavaObject.getNoCopy(null, getBytesNoCopy()); switch (getType()) { case BYTES: return ValueLob.createSmallLob(Value.BLOB, getBytesNoCopy()); switch (getType()) { case BYTES: return ValueUuid.get(getBytesNoCopy());
case Value.BYTES: case Value.JAVA_OBJECT: writeBytes(v.getBytesNoCopy()); break; case Value.UUID: {
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;
break; case EXPAND: result = ValueBytes.getNoCopy(CompressTool.getInstance().expand(v0.getBytesNoCopy())); break; case ZERO: break; case UTF8TOSTRING: result = ValueString.get(new String(v0.getBytesNoCopy(), Constants.UTF8)); break; case XMLCOMMENT: