⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcblob.java

📁 hsql是很有名的嵌入式数据库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }            return i + 1;        }        return -1;    }    /**     * Retrieves the byte position in the <code>BLOB</code> value     * designated by this <code>Blob</code> object at which     * <code>pattern</code> begins.  The search begins at position     * <code>start</code>.     *     * @param pattern the <code>Blob</code> object designating     *      the <code>BLOB</code> value for which to search     * @param start the position in the <code>BLOB</code> value     *        at which to begin searching; the first position is 1     * @return the position at which the pattern begins, else -1     * @exception SQLException if there is an error accessing the     *        <code>BLOB</code> value     *     * @since JDK 1.2, HSQLDB 1.7.2     */    public long position(final Blob pattern, long start) throws SQLException {        final byte[] ldata = data;        final int    dlen  = ldata.length;        if (start > dlen || pattern == null) {            return -1;        } else if (start < 1) {            start = 0;        } else {            start--;        }        final long plen = pattern.length();        if (plen == 0 || start > ((long) dlen) - plen) {            return -1;        }        // by now, we know plen <= Integer.MAX_VALUE        final int iplen = (int) plen;        byte[]    bap;        if (pattern instanceof jdbcBlob) {            bap = ((jdbcBlob) pattern).data;        } else {            bap = pattern.getBytes(1, iplen);        }        final int  stop = dlen - iplen;        final byte b0   = bap[0];        outer_loop:        for (int i = (int) start; i <= stop; i++) {            if (ldata[i] != b0) {                continue;            }            int len     = iplen;            int doffset = i;            int poffset = 0;            while (len-- > 0) {                if (ldata[doffset++] != bap[poffset++]) {                    continue outer_loop;                }            }            return i + 1;        }        return -1;    }    // -------------------------- JDBC 3.0 -----------------------------------    /**     * Writes the given array of bytes to the <code>BLOB</code> value that     * this <code>Blob</code> object represents, starting at position     * <code>pos</code>, and returns the number of bytes written. <p>     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * HSLQDB 1.7.2 does not support this feature. <p>     *     * Calling this method always throws an <code>SQLException</code>.     * </div>     * <!-- end release-specific documentation -->     *     * @param pos the position in the <code>BLOB</code> object at which     *        to start writing     * @param bytes the array of bytes to be written to the <code>BLOB</code>     *        value that this <code>Blob</code> object represents     * @return the number of bytes written     * @exception SQLException if there is an error accessing the     *            <code>BLOB</code> value     * @see #getBytes     *     * @since JDK 1.4, HSQLDB 1.7.2     */    public int setBytes(long pos, byte[] bytes) throws SQLException {        throw Util.notSupported;    }    /**     * Writes all or part of the given <code>byte</code> array to the     * <code>BLOB</code> value that this <code>Blob</code> object represents     * and returns the number of bytes written.     * Writing starts at position <code>pos</code> in the <code>BLOB</code>     * value; <code>len</code> bytes from the given byte array are written. <p>     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * HSLQDB 1.7.2 does not support this feature. <p>     *     * Calling this method always throws an <code>SQLException</code>.     * </div>     * <!-- end release-specific documentation -->     *     * @param pos the position in the <code>BLOB</code> object at which     *        to start writing     * @param bytes the array of bytes to be written to this <code>BLOB</code>     *        object     * @param offset the offset into the array <code>bytes</code> at which     *        to start reading the bytes to be set     * @param len the number of bytes to be written to the <code>BLOB</code>     *        value from the array of bytes <code>bytes</code>     * @return the number of bytes written     * @exception SQLException if there is an error accessing the     *            <code>BLOB</code> value     * @see #getBytes     *     * @since JDK 1.4, HSQLDB 1.7.2     */    public int setBytes(long pos, byte[] bytes, int offset,                        int len) throws SQLException {        throw Util.notSupported;    }    /**     * Retrieves a stream that can be used to write to the <code>BLOB</code>     * value that this <code>Blob</code> object represents.  The stream begins     * at position <code>pos</code>. <p>     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * HSQLDB 1.7.2 does not support this feature. <p>     *     * Calling this method always throws an <code>SQLException</code>.     * </div>     * <!-- end release-specific documentation -->     *     * @param pos the position in the <code>BLOB</code> value at which     *        to start writing     * @return a <code>java.io.OutputStream</code> object to which data can     *         be written     * @exception SQLException if there is an error accessing the     *            <code>BLOB</code> value     * @see #getBinaryStream     *     * @since JDK 1.4, HSQLDB 1.7.2     */    public OutputStream setBinaryStream(long pos) throws SQLException {        throw Util.notSupported;    }    /**     * Truncates the <code>BLOB</code> value that this <code>Blob</code>     * object represents to be <code>len</code> bytes in length.     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * This operation affects only the client-side value; it has no effect upon     * the value as it is stored in the database.     * </div>     * <!-- end release-specific documentation -->     *     * @param len the length, in bytes, to which the <code>BLOB</code> value     *        that this <code>Blob</code> object represents should be truncated     * @exception SQLException if there is an error accessing the     *            <code>BLOB</code> value     *     * @since JDK 1.4, HSQLDB 1.7.2     */    public void truncate(final long len) throws SQLException {        final byte[] ldata = data;        if (len < 0 || len > ldata.length) {            throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT,                                    Long.toString(len));        }        if (len == ldata.length) {            return;        }        byte[] newData = new byte[(int) len];        System.arraycopy(ldata, 0, newData, 0, (int) len);        data = newData;    }//    public static void main(String[] args) throws Exception {////        System.out.println("--------------------------------");//        System.out.println((new jdbcBlob(new byte[0])).position(new byte[]{1}, 1));//        System.out.println((new jdbcBlob(new byte[]{1})).position(new byte[0], 1));//        System.out.println((new jdbcBlob(new byte[]{1})).position((byte[])null, 1));////        System.out.println("--------------------------------");//        byte[] data1 = new byte[]{0,1,2,1,2,3,2,3,4,2,3,4,5,2,3,4,5,0,1,2,//                                  1,2,3,2,3,4,2,3,4,5,2,3,4};//        byte[] pattern = new byte[]{2,3,4,5};////        jdbcBlob blob1 = new jdbcBlob(data1);//        jdbcBlob blob2 = new jdbcBlob(pattern);////        for (int i = -1; i <= data1.length + 1; i++) {//            System.out.println(blob1.position(pattern, i));//        }////        System.out.println("--------------------------------");////        for (int i = -1; i <= data1.length + 1; i++) {//            System.out.println(blob1.position(blob2, i));//        }////        System.out.println("--------------------------------");////        new jdbcBlob(null);//    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -