/** * {@collect.stats} Constructs a <code>SerialBlob</code> object that is a serialized version of * the given <code>Blob</code> object. * * <p>The new <code>SerialBlob</code> object is initialized with the data from the <code>Blob * </code> object; therefore, the <code>Blob</code> object should have previously brought the SQL * <code>BLOB</code> value's data over to the client from the database. Otherwise, the new <code> * SerialBlob</code> object will contain no data. * * @param blob the <code>Blob</code> object from which this <code>SerialBlob</code> object is to * be constructed; cannot be null. * @throws SerialException if an error occurs during serialization * @throws SQLException if the <code>Blob</code> passed to this to this constructor is a <code> * null</code>. * @see java.sql.Blob */ public SerialBlob(Blob blob) throws SerialException, SQLException { if (blob == null) { throw new SQLException("Cannot instantiate a SerialBlob " + "object with a null Blob object"); } len = blob.length(); buf = blob.getBytes(1, (int) len); this.blob = blob; // if ( len < 10240000) // len = 10240000; origLen = len; }
/** * {@collect.stats} Returns the position in this <code>SerialBlob</code> object where the given * <code>Blob</code> object begins, starting the search at the specified position. * * @param pattern the <code>Blob</code> object for which to search; * @param start the position of the byte in this <code>SerialBlob</code> object from which to * begin the search; the first position is <code>1</code>; must not be less than <code>1 * </code> nor greater than the length of this <code>SerialBlob</code> object * @return the position in this <code>SerialBlob</code> object where the given <code>Blob</code> * object begins, starting at the specified position; <code>-1</code> if the pattern is not * found or the given starting position is out of bounds; position numbering for the return * value starts at <code>1</code> * @throws SerialException if an error occurs when serializing the blob * @throws SQLException if there is an error accessing the <code>BLOB</code> value from the * database */ public long position(Blob pattern, long start) throws SerialException, SQLException { return position(pattern.getBytes(1, (int) (pattern.length())), start); }