/** * @return the current position within the object * @throws SQLException if a database-access error occurs. */ public int tell() throws SQLException { FastpathArg[] args = new FastpathArg[1]; args[0] = new FastpathArg(fd); return fp.getInteger("lo_tell", args); }
/** * Writes an array to the object. * * @param buf array to write * @throws SQLException if a database-access error occurs. */ public void write(byte[] buf) throws SQLException { FastpathArg[] args = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(buf); fp.fastpath("lowrite", args); }
/** * @return the current position within the object * @throws SQLException if a database-access error occurs. */ public long tell64() throws SQLException { FastpathArg[] args = new FastpathArg[1]; args[0] = new FastpathArg(fd); return fp.getLong("lo_tell64", args); }
/** * This deletes a large object. * * @param oid describing object to delete * @throws SQLException on error */ public void delete(long oid) throws SQLException { FastpathArg[] args = new FastpathArg[1]; args[0] = Fastpath.createOIDArg(oid); fp.fastpath("lo_unlink", args); }
/** * Reads some data from the object, and return as a byte[] array. * * @param len number of bytes to read * @return byte[] array containing data read * @throws SQLException if a database-access error occurs. */ public byte[] read(int len) throws SQLException { // This is the original method, where the entire block (len bytes) // is retrieved in one go. FastpathArg[] args = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(len); return fp.getData("loread", args); }
/** * This convenience method assumes that the return value is not an Integer. * * @param name Function name * @param args Function arguments * @return byte[] array containing result * @throws SQLException if a database-access error occurs or no result */ public byte[] getData(String name, FastpathArg[] args) throws SQLException { return fastpath(name, args); }
/** * Creates a FastpathArg with an oid parameter. * This is here instead of a constructor of FastpathArg * because the constructor can't tell the difference between * an long that's really int8 and a long thats an oid. */ public static FastpathArg createOIDArg(long oid) { if (oid > Integer.MAX_VALUE) oid -= NUM_OIDS; return new FastpathArg((int)oid); }
/** * This convenience method assumes that the return value is an oid. * @param name Function name * @param args Function arguments * @exception SQLException if a database-access error occurs or no result */ public long getOID(String name, FastpathArg[] args) throws SQLException { long oid = getInteger(name, args); if (oid < 0) oid += NUM_OIDS; return oid; }
/** * Truncates the large object to the given length in bytes. If the number of bytes is larger than * the current large object length, the large object will be filled with zero bytes. This method * does not modify the current file offset. * * @param len given length in bytes * @throws SQLException if something goes wrong */ public void truncate64(long len) throws SQLException { FastpathArg[] args = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(len); fp.getInteger("lo_truncate64", args); }
/** * Writes some data from an array to the object. * * @param buf destination array * @param off offset within array * @param len number of bytes to write * @throws SQLException if a database-access error occurs. */ public void write(byte[] buf, int off, int len) throws SQLException { FastpathArg[] args = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(buf, off, len); fp.fastpath("lowrite", args); }
/** * This deletes a large object. * * @param oid describing object to delete * @exception SQLException on error */ public void delete(long oid) throws SQLException { FastpathArg args[] = new FastpathArg[1]; args[0] = Fastpath.createOIDArg(oid); fp.fastpath("lo_unlink", false, args); }
/** * Reads some data from the object, and return as a byte[] array * * @param len number of bytes to read * @return byte[] array containing data read * @exception SQLException if a database-access error occurs. */ public byte[] read(int len) throws SQLException { // This is the original method, where the entire block (len bytes) // is retrieved in one go. FastpathArg args[] = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(len); return fp.getData("loread", args); }
/** * This convenience method assumes that the return value is not an Integer * @param name Function name * @param args Function arguments * @return byte[] array containing result * @exception SQLException if a database-access error occurs or no result */ public byte[] getData(String name, FastpathArg[] args) throws SQLException { return (byte[])fastpath(name, false, args); }
/** * Creates a FastpathArg with an oid parameter. This is here instead of a constructor of * FastpathArg because the constructor can't tell the difference between an long that's really * int8 and a long thats an oid. * * @param oid input oid * @return FastpathArg with an oid parameter */ public static FastpathArg createOIDArg(long oid) { if (oid > Integer.MAX_VALUE) { oid -= NUM_OIDS; } return new FastpathArg((int) oid); }
/** * @return the current position within the object * @exception SQLException if a database-access error occurs. */ public int tell() throws SQLException { FastpathArg args[] = new FastpathArg[1]; args[0] = new FastpathArg(fd); return fp.getInteger("lo_tell", args); }
/** * Sets the current position within the object using 64-bit value (9.3+). * * @param pos position within object * @param ref Either SEEK_SET, SEEK_CUR or SEEK_END * @throws SQLException if a database-access error occurs. */ public void seek64(long pos, int ref) throws SQLException { FastpathArg[] args = new FastpathArg[3]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(pos); args[2] = new FastpathArg(ref); fp.fastpath("lo_lseek64", args); }
/** * Truncates the large object to the given length in bytes. If the number of bytes is larger than * the current large object length, the large object will be filled with zero bytes. This method * does not modify the current file offset. * * @param len given length in bytes * @throws SQLException if something goes wrong */ public void truncate(int len) throws SQLException { FastpathArg[] args = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(len); fp.getInteger("lo_truncate", args); }
/** * Writes an array to the object * * @param buf array to write * @exception SQLException if a database-access error occurs. */ public void write(byte buf[]) throws SQLException { FastpathArg args[] = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(buf); fp.fastpath("lowrite", false, args); }
/** * Truncates the large object to the given length in bytes. * If the number of bytes is larger than the current large * object length, the large object will be filled with zero * bytes. This method does not modify the current file offset. */ public void truncate(int len) throws SQLException { FastpathArg args[] = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(len); fp.getInteger("lo_truncate", args); }
/** * Writes some data from an array to the object * * @param buf destination array * @param off offset within array * @param len number of bytes to write * @exception SQLException if a database-access error occurs. */ public void write(byte buf[], int off, int len) throws SQLException { FastpathArg args[] = new FastpathArg[2]; args[0] = new FastpathArg(fd); args[1] = new FastpathArg(buf, off, len); fp.fastpath("lowrite", false, args); }