/** * Create a Clob value from this reader. * * @param x the reader * @param length the length (if smaller or equal than 0, all data until the * end of file is read) * @return the value */ public Value createClob(Reader x, long length) { if (x == null) { return ValueNull.INSTANCE; } if (length <= 0) { length = -1; } Value v = ValueLobDb.createTempClob(x, length); session.addTemporaryLob(v); return v; }
@Override public Value convertPrecision(long precision, boolean force) { if (this.precision <= precision) { return this; } ValueLobDb lob; if (type == CLOB) { lob = ValueLobDb.createTempClob(getReader(), precision); } else { lob = ValueLobDb.createTempBlob(getInputStream(), precision); } return lob; }
/** * Create a new empty Clob object. * * @return the object */ @Override public Clob createClob() throws SQLException { try { int id = getNextId(TraceObject.CLOB); debugCodeAssign("Clob", TraceObject.CLOB, id, "createClob()"); checkClosed(); try { Value v = ValueLobDb.createTempClob(new InputStreamReader(new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0); session.addTemporaryLob(v); return new JdbcClob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
/** * Create a new empty NClob object. * * @return the object */ @Override public NClob createNClob() throws SQLException { try { int id = getNextId(TraceObject.CLOB); debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()"); checkClosed(); try { Value v = ValueLobDb.createTempClob( new InputStreamReader( new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0); session.addTemporaryLob(v); return new JdbcClob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
v = ValueNull.INSTANCE; } else { v = ValueLobDb.createTempClob(new BufferedReader(in), -1);
} else if (x instanceof java.io.Reader) { Reader r = new BufferedReader((java.io.Reader) x); return ValueLobDb.createTempClob(r, -1); } else if (x instanceof java.sql.Clob) { try { Reader r = new BufferedReader( ((java.sql.Clob) x).getCharacterStream()); return ValueLobDb.createTempClob(r, -1); } catch (SQLException e) { throw DbException.convert(e);
/** * Convert a lob to another data type. The data is fully read in memory * except when converting to BLOB or CLOB. * * @param t the new type * @return the converted value */ @Override public Value convertTo(int t) { if (t == type) { return this; } else if (t == Value.CLOB) { if (small != null) { return ValueLobDb.createSmallLob(t, small); } else { return ValueLobDb.createTempClob(getReader(), -1); } } else if (t == Value.BLOB) { if (small != null) { return ValueLobDb.createSmallLob(t, small); } else { return ValueLobDb.createTempBlob(getInputStream(), -1); } } return super.convertTo(t); }