diff options
| author | Bruce Momjian <bruce@momjian.us> | 2001-10-25 06:00:05 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2001-10-25 06:00:05 +0000 |
| commit | d2e27b0674e238a4f94f1c190a395a530746d5d3 (patch) | |
| tree | d654e117fdc20ecb84da14052fad5124c9f32012 /src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java | |
| parent | b81844b1738c584d92330a5ccd0fbd8b603d2886 (diff) | |
| download | postgresql-d2e27b0674e238a4f94f1c190a395a530746d5d3.tar.gz | |
pgjindent jdbc files. First time jdbc files were formatted.
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java')
| -rw-r--r-- | src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java | 291 |
1 files changed, 145 insertions, 146 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java b/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java index 6f79711c70..03445c01b7 100644 --- a/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java +++ b/src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java @@ -32,7 +32,7 @@ import org.postgresql.util.*; * </pre> * * <p>Normally, client code would use the getAsciiStream, getBinaryStream, - * or getUnicodeStream methods in ResultSet, or setAsciiStream, + * or getUnicodeStream methods in ResultSet, or setAsciiStream, * setBinaryStream, or setUnicodeStream methods in PreparedStatement to * access Large Objects. * @@ -58,149 +58,148 @@ import org.postgresql.util.*; */ public class LargeObjectManager { - // the fastpath api for this connection - private Fastpath fp; - - /** - * This mode indicates we want to write to an object - */ - public static final int WRITE = 0x00020000; - - /** - * This mode indicates we want to read an object - */ - public static final int READ = 0x00040000; - - /** - * This mode is the default. It indicates we want read and write access to - * a large object - */ - public static final int READWRITE = READ | WRITE; - - /** - * This prevents us being created by mere mortals - */ - private LargeObjectManager() - { - } - - /** - * Constructs the LargeObject API. - * - * <p><b>Important Notice</b> - * <br>This method should only be called by org.postgresql.Connection - * - * <p>There should only be one LargeObjectManager per Connection. The - * org.postgresql.Connection class keeps track of the various extension API's - * and it's advised you use those to gain access, and not going direct. - */ - public LargeObjectManager(org.postgresql.Connection conn) throws SQLException - { - // We need Fastpath to do anything - this.fp = conn.getFastpathAPI(); - - // Now get the function oid's for the api - // - // This is an example of Fastpath.addFunctions(); - // - java.sql.ResultSet res = (java.sql.ResultSet)conn.createStatement().executeQuery("select proname, oid from pg_proc" + - " where proname = 'lo_open'" + - " or proname = 'lo_close'" + - " or proname = 'lo_creat'" + - " or proname = 'lo_unlink'" + - " or proname = 'lo_lseek'" + - " or proname = 'lo_tell'" + - " or proname = 'loread'" + - " or proname = 'lowrite'"); - - if(res==null) - throw new PSQLException("postgresql.lo.init"); - - fp.addFunctions(res); - res.close(); - DriverManager.println("Large Object initialised"); - } - - /** - * This opens an existing large object, based on its OID. This method - * assumes that READ and WRITE access is required (the default). - * - * @param oid of large object - * @return LargeObject instance providing access to the object - * @exception SQLException on error - */ - public LargeObject open(int oid) throws SQLException - { - return new LargeObject(fp,oid,READWRITE); - } - - /** - * This opens an existing large object, based on its OID - * - * @param oid of large object - * @param mode mode of open - * @return LargeObject instance providing access to the object - * @exception SQLException on error - */ - public LargeObject open(int oid,int mode) throws SQLException - { - return new LargeObject(fp,oid,mode); - } - - /** - * This creates a large object, returning its OID. - * - * <p>It defaults to READWRITE for the new object's attributes. - * - * @return oid of new object - * @exception SQLException on error - */ - public int create() throws SQLException - { - FastpathArg args[] = new FastpathArg[1]; - args[0] = new FastpathArg(READWRITE); - return fp.getInteger("lo_creat",args); - } - - /** - * This creates a large object, returning its OID - * - * @param mode a bitmask describing different attributes of the new object - * @return oid of new object - * @exception SQLException on error - */ - public int create(int mode) throws SQLException - { - FastpathArg args[] = new FastpathArg[1]; - args[0] = new FastpathArg(mode); - return fp.getInteger("lo_creat",args); - } - - /** - * This deletes a large object. - * - * @param oid describing object to delete - * @exception SQLException on error - */ - public void delete(int oid) throws SQLException - { - FastpathArg args[] = new FastpathArg[1]; - args[0] = new FastpathArg(oid); - fp.fastpath("lo_unlink",false,args); - } - - /** - * This deletes a large object. - * - * <p>It is identical to the delete method, and is supplied as the C API uses - * unlink. - * - * @param oid describing object to delete - * @exception SQLException on error - */ - public void unlink(int oid) throws SQLException - { - delete(oid); - } - + // the fastpath api for this connection + private Fastpath fp; + + /** + * This mode indicates we want to write to an object + */ + public static final int WRITE = 0x00020000; + + /** + * This mode indicates we want to read an object + */ + public static final int READ = 0x00040000; + + /** + * This mode is the default. It indicates we want read and write access to + * a large object + */ + public static final int READWRITE = READ | WRITE; + + /** + * This prevents us being created by mere mortals + */ + private LargeObjectManager() + {} + + /** + * Constructs the LargeObject API. + * + * <p><b>Important Notice</b> + * <br>This method should only be called by org.postgresql.Connection + * + * <p>There should only be one LargeObjectManager per Connection. The + * org.postgresql.Connection class keeps track of the various extension API's + * and it's advised you use those to gain access, and not going direct. + */ + public LargeObjectManager(org.postgresql.Connection conn) throws SQLException + { + // We need Fastpath to do anything + this.fp = conn.getFastpathAPI(); + + // Now get the function oid's for the api + // + // This is an example of Fastpath.addFunctions(); + // + java.sql.ResultSet res = (java.sql.ResultSet)conn.createStatement().executeQuery("select proname, oid from pg_proc" + + " where proname = 'lo_open'" + + " or proname = 'lo_close'" + + " or proname = 'lo_creat'" + + " or proname = 'lo_unlink'" + + " or proname = 'lo_lseek'" + + " or proname = 'lo_tell'" + + " or proname = 'loread'" + + " or proname = 'lowrite'"); + + if (res == null) + throw new PSQLException("postgresql.lo.init"); + + fp.addFunctions(res); + res.close(); + DriverManager.println("Large Object initialised"); + } + + /** + * This opens an existing large object, based on its OID. This method + * assumes that READ and WRITE access is required (the default). + * + * @param oid of large object + * @return LargeObject instance providing access to the object + * @exception SQLException on error + */ + public LargeObject open(int oid) throws SQLException + { + return new LargeObject(fp, oid, READWRITE); + } + + /** + * This opens an existing large object, based on its OID + * + * @param oid of large object + * @param mode mode of open + * @return LargeObject instance providing access to the object + * @exception SQLException on error + */ + public LargeObject open(int oid, int mode) throws SQLException + { + return new LargeObject(fp, oid, mode); + } + + /** + * This creates a large object, returning its OID. + * + * <p>It defaults to READWRITE for the new object's attributes. + * + * @return oid of new object + * @exception SQLException on error + */ + public int create() throws SQLException + { + FastpathArg args[] = new FastpathArg[1]; + args[0] = new FastpathArg(READWRITE); + return fp.getInteger("lo_creat", args); + } + + /** + * This creates a large object, returning its OID + * + * @param mode a bitmask describing different attributes of the new object + * @return oid of new object + * @exception SQLException on error + */ + public int create(int mode) throws SQLException + { + FastpathArg args[] = new FastpathArg[1]; + args[0] = new FastpathArg(mode); + return fp.getInteger("lo_creat", args); + } + + /** + * This deletes a large object. + * + * @param oid describing object to delete + * @exception SQLException on error + */ + public void delete(int oid) throws SQLException + { + FastpathArg args[] = new FastpathArg[1]; + args[0] = new FastpathArg(oid); + fp.fastpath("lo_unlink", false, args); + } + + /** + * This deletes a large object. + * + * <p>It is identical to the delete method, and is supplied as the C API uses + * unlink. + * + * @param oid describing object to delete + * @exception SQLException on error + */ + public void unlink(int oid) throws SQLException + { + delete(oid); + } + } |
