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

📄 serialclob.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * <code>-1</code> if the pattern is not found.     *     * @param searchStr the <code>String</code> object for which to     *                  search     * @param start the position in this <code>SerialClob</code> object     *         at which to start 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>SerialClob</code> object          * @return the position at which the given <code>String</code> object     *         begins, starting the search at the specified position;     *         <code>-1</code> if the given <code>String</code> object is     *         not found or the starting position is out of bounds; position     *         numbering for the return value starts at <code>1</code>	     * @throws SerialException if an error occurs locating the String signature     * @throws SQLException if there is an error accessing the Blob value 	     *         from the database.               */    public long position(String searchStr, long start)         throws SerialException, SQLException {                      if (start < 1 || start > len) {            return -1;        }                                     char pattern[] = searchStr.toCharArray();        int pos = (int)start-1;        int i = 0;                long patlen = pattern.length;                                while (pos < len) {                 if (pattern[i] == buf[pos]) {                                if (i + 1 == patlen) {                    return (pos + 1) - (patlen - 1);                }                               i++; pos++; // increment pos, and i            } else if (pattern[i] != buf[pos]) {                pos++; // increment pos only            }                                            }                return -1; // not found                }	    /**     * Returns the position in this <code>SerialClob</code> object     * where the given <code>Clob</code> signature begins, starting     * the search at the specified position. This method returns     * <code>-1</code> if the pattern is not found.     *     * @param searchStr the <code>Clob</code> object for which to search     * @param start the position in this <code>SerialClob</code> object     *        at 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>SerialClob</code> object      * @return the position at which the given <code>Clob</code>      *         object begins in this <code>SerialClob</code> object,     *         at or after the specified starting position     * @throws SerialException if an error occurs locating the Clob signature     * @throws SQLException if there is an error accessing the Blob value 	     *         from the database             */    public long position(Clob searchStr, long start)         throws SerialException, SQLException {                    return position(searchStr.getSubString(1,(int)searchStr.length()), start);       }        /**     * Writes the given Java <code>String</code> to the <code>CLOB</code>     * value that this <code>SerialClob</code> object represents, at the position      * <code>pos</code>.     *     * @param pos the position at which to start writing to the <code>CLOB</code>     *         value that this <code>SerialClob</code> object represents; the first      *         position is <code>1</code>; must not be less than <code>1</code> nor     *         greater than the length of this <code>SerialClob</code> object      * @param str the string to be written to the <code>CLOB</code>     *        value that this <code>SerialClob</code> object represents     * @return the number of characters written     * @throws SerialException if there is an error accessing the      *     <code>CLOB</code> value; if an invalid position is set; if an      *     invalid offset value is set; if number of bytes to be written     *     is greater than the <code>SerialClob</code> length; or the combined     *     values of the length and offset is greater than the Clob buffer                  */    public int setString(long pos, String str) throws SerialException {                return (setString(pos, str, 0, str.length()));    }        /**     * Writes <code>len</code> characters of <code>str</code>, starting      * at character <code>offset</code>, to the <code>CLOB</code> value     * that this <code>Clob</code> represents.     *     * @param pos the position at which to start writing to the <code>CLOB</code>     *         value that this <code>SerialClob</code> object represents; the first      *         position is <code>1</code>; must not be less than <code>1</code> nor     *         greater than the length of this <code>SerialClob</code> object     * @param str the string to be written to the <code>CLOB</code>      *        value that this <code>Clob</code> object represents     * @param offset the offset into <code>str</code> to start reading     *        the characters to be written     * @param length the number of characters to be written     * @return the number of characters written     * @throws SerialException if there is an error accessing the      *     <code>CLOB</code> value; if an invalid position is set; if an      *     invalid offset value is set; if number of bytes to be written     *     is greater than the <code>SerialClob</code> length; or the combined     *     values of the length and offset is greater than the Clob buffer          */    public int setString(long pos, String str, int offset, int length)         throws SerialException {                String temp = str.substring(offset);        char cPattern[] = temp.toCharArray();                 if (offset < 0 || offset > str.length()) {            throw new SerialException("Invalid offset in byte array set");        }                            if (pos < 1 || pos > this.length()) {            throw new SerialException("Invalid position in BLOB object set");        }                            if ((long)(length) > origLen) {	    throw new SerialException("Buffer is not sufficient to hold the value");	}                    if ((length + offset) > str.length()) {              // need check to ensure length + offset !> bytes.length            throw new SerialException("Invalid OffSet. Cannot have combined offset " +                " and length that is greater that the Blob buffer");                    }                                                       int i = 0;        pos--;  //values in the array are at position one less        while ( i < length || (offset + i +1) < (str.length() - offset ) ) {            this.buf[(int)pos + i ] = cPattern[offset + i ];             i++;        }        return i;                    }        /**     * Retrieves a stream to be used to write Ascii characters to the     * <code>CLOB</code> value that this <code>SerialClob</code> object represents,      * starting at position <code>pos</code>. This method forwards the      * <code>setAsciiStream()</code> call to the underlying <code>Clob</code> object in      * the event that this <code>SerialClob</code> object is instantiated with a      * <code>Clob</code> object. If this <code>SerialClob</code> object is instantiated     *  with a <code>char</code> array, a <code>SerialException</code> object is thrown.     *     * @param pos the position at which to start writing to the     *        <code>CLOB</code> object     * @return the stream to which ASCII encoded characters can be written     * @throws SerialException if SerialClob is not instantiated with a     *     Clob object that supports <code>setAsciiStream</code>     * @throws SQLException if there is an error accessing the      *     <code>CLOB</code> value          * @see #getAsciiStream     */    public java.io.OutputStream setAsciiStream(long pos)         throws SerialException, SQLException {              if (this.clob.setAsciiStream(pos) != null) {             return this.clob.setAsciiStream(pos);         } else {                               throw new SerialException("Unsupported operation. SerialClob cannot " +                "return a writable ascii stream\n unless instantiated with a Clob object " +                "that has a setAsciiStream() implementation");         }             }        /**     * Retrieves a stream to be used to write a stream of Unicode characters      * to the <code>CLOB</code> value that this <code>SerialClob</code> object     * represents, at position <code>pos</code>. This method forwards the      * <code>setCharacterStream()</code> call to the underlying <code>Clob</code>      * object in the event that this <code>SerialClob</code> object is instantiated with a      * <code>Clob</code> object. If this <code>SerialClob</code> object is instantiated with     * a <code>char</code> array, a <code>SerialException</code> is thrown.     *     * @param  pos the position at which to start writing to the     *        <code>CLOB</code> value     *     * @return a stream to which Unicode encoded characters can be written     * @throws SerialException if the SerialClob is not instantiated with     *     a Clob object that supports <code>setCharacterStream</code>     * @throws SQLException if there is an error accessing the      *            <code>CLOB</code> value     * @see #getCharacterStream     */    public java.io.Writer setCharacterStream(long pos)         throws SerialException, SQLException {         if (this.clob.setCharacterStream(pos) != null) {            return this.clob.setCharacterStream(pos);        } else {            throw new SerialException("Unsupported operation. SerialClob cannot " +                "return a writable character stream\n unless instantiated with a Clob object " +                "that has a setCharacterStream implementation");        }    }        /**     * Truncates the <code>CLOB</code> value that this <code>SerialClob</code>      * object represents so that it has a length of <code>len</code>     * characters.      * <p>     * Truncating a <code>SerialClob</code> object to length 0 has the effect of      * clearing its contents.     *     * @param length the length, in bytes, to which the <code>CLOB</code>     *        value should be truncated     * @throws SQLException if there is an error accessing the      *        <code>CLOB</code> value     */    public void truncate(long length) throws SerialException {                 if (length > len) {            throw new SerialException               ("Length more than what can be truncated");         } else {                    len = length;              // re-size the buffer                             if (len == 0) {                  buf = new char[] {};              } else {                buf = (this.getSubString(1, (int)len)).toCharArray();              }                       }      }    public Reader getCharacterStream(long pos, long length) throws SQLException {        throw new java.lang.UnsupportedOperationException("Not supported");    }    public void free() throws SQLException {        throw new java.lang.UnsupportedOperationException("Not supported");    }    /**	 * The identifier that assists in the serialization of this <code>SerialClob</code>     * object.     */    static final long serialVersionUID = -1662519690087375313L;}

⌨️ 快捷键说明

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