public InputStream getInputStream() { return new ByteArrayInputStream(getBytesNoCopy()); }
public byte[] getBytesNoCopy() { return convertTo(Value.BYTES).getBytesNoCopy(); }
@Override protected int compareSecure(Value v, CompareMode mode) { 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) { if (v instanceof ValueLobDb) { ValueLobDb v2 = (ValueLobDb) 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, fileName); } }
@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 = getNextId(TraceObject.CLOB); o = new JdbcClob(this, v, id); break; } case Value.BLOB: { int id = getNextId(TraceObject.BLOB); o = new JdbcBlob(this, v, id); break; } case Value.JAVA_OBJECT: if (SysProperties.serializeJavaObject) { o = JdbcUtils.deserialize(v.getBytesNoCopy()); break; } default: o = v.getObject(); } return o; }
case JAVA_OBJECT: case BLOB: return ValueBytes.getNoCopy(getBytesNoCopy()); case UUID: return ValueBytes.getNoCopy(getBytes()); case BLOB: return ValueJavaObject.getNoCopy( null, getBytesNoCopy()); case BYTES: return ValueLobDb.createSmallLob( Value.BLOB, getBytesNoCopy()); switch (getType()) { case BYTES: return ValueUuid.get(getBytesNoCopy());
break; case UTF8TOSTRING: result = ValueString.get(new String(v0.getBytesNoCopy(), Constants.UTF8), database.getMode().treatEmptyStringsAsNull);