Red Hat Database is an extensible database system that is based on PostgreSQL. You can add your own functions and data types to the backend. These facilities, which are unique to PostgreSQL, are supported from Java with a set of extension APIs.
All extensions are found within the org.postgresql package, typically as sub-packages. The list below gives the available packages and gives a short description of each.
Contains Red Hat Database's implementation of java.sql.Connection, which includes additional methods that provide access to other extensions including Fastpath and LargeObjectManager.
Includes the Fastpath and FastpathArg classes. These classes are a Java implementation of the libpq Fastpath mechanism, which enables backend functions to be executed by clients.
Consists of two classes, LargeObjectManager, which deals with creating, opening and deleting large objects, and LargeObject, which deals with an individual object.
Contains the Serializable, PGobject, and PGmoney classes as well as the utility classes PGtokenizer and UnixCrypt.
Red Hat Database has a set of data types that allow for the storage of geometric features in a table. These include points, lines, and polygons. These types are supported in Java through the org.postgresql.geometric package. It contains classes that extend the org.postgresql.util.PGobject class.
The Connection class, part of the org.postgresql package, is the Red Hat Database JDBC driver's implementation of java.sql.Connection. The org.postgresql.Connection defines three methods in addition to the methods required by the java.sql.Connection interface.
package org.postgresql; public class Connection implements java.sql.Connection { // Methods (new; java.sql.Connection methods not listed) public void addDataType(String type, String name); public Fastpath getFastpathAPI() throws SQLException; public LargeObjectManager getLargeObjectAPI() throws SQLException; } |
This method allows client code to add handlers for data types unique to Red Hat Database, including user-defined data types. Normally, a data type not known by the driver is returned by ResultSet.getObject() as a PGobject instance. The addDataType method enables you to tell the driver the type name and class name to be used instead. The custom class must inherit from PGobject. Handler registration is per connection instance, so this method needs to be called each time a database connection is made.
Parameters.
The name of the data type.
The fully qualified name of the handler class that should be used for the type.
Example.
import org.postgresql.Connection; ... ((org.postgresql.Connection) con).addDataType("mytype", "my.class.name"); |
This returns the Fastpath API of the connection.
Example.
import org.postgresql.Connection; import org.postgresql.fastpath.*; ... Fastpath fp = ((org.postgresql.Connection) con).getFastpathAPI(); |
This returns the LargeObjectManager that the connection is using.
Example.
import org.postgresql.Connection; import org.postgresql.largeobject.*; ... LargeObjectManager lom = ((org.postgresql.Connection) con).getLargeObjectAPI(); |
Fastpath is an API that allows a client machine to execute a function on the database backend. Most client code will not need to use this method, but it is provided because the Large Object API uses it.
To use the Fastpath as an API, you need to import the org.postgresql.fastpath package in the preamble of the source file in which Fastpath will be used. A Fastpath object that is associated with a given database connection can be obtained by requesting one from the Connection object (cast to org.postgresql.Connection). For example:
import org.postgresql.Connection; import org.postgresql.fastpath.*; ... Fastpath fp = ((org.postgresql.Connection) con).getFastpathAPI(); |
package org.postgresql.fastpath; public class Fastpath { // Methods public void addFunction(String name, int fnid); public void addFunctions(ResultSet rs) throws SQLException; public Object fastpath(int field, boolean resulttype, FastpathArg args[]) throws SQLException; public Object fastpath(String name, boolean resulttype, FastpathArg args[]) throws SQLException; public byte[] getData(String name, FastpathArg args[]) throws SQLException; public int getID(String name) throws SQLException; public int getInteger(String name, FastpathArg args[]) throws SQLException; } |
This method adds a function to the function name-to-OID look-up table used internally by the Fastpath API. User code should use the addFunctions method, which is based upon a query, rather than hard coding the OID as the OID for a function is not guaranteed to remain static even on different servers of the same version.
Parameters.
The name of the function.
The OID of the function.
This method takes a ResultSet containing two columns as its argument. The first column contains a function name; the second contains that function's OID. The addFunctions method reads the entire ResultSet, loading the values into its internal function name-to-OID mapping table.
Parameters.
The ResultSet.
This method sends a function call to the Red Hat Database backend that the Fastpath object is associated with. This version of Fastpath calls a function by OID.
Parameters.
The OID of the function to call.
True if the result is an integer, false for other results.
Fastpath arguments.
Returns. If no data, null; if the result of the function call is an integer, an Integer; otherwise: byte[]
The fastpath method sends a function call to the Red Hat Database backend that the Fastpath object is associated with. This version of Fastpath calls a function by name.
Parameters.
The name of the function to call.
True if the result is an integer, false for other results.
Fastpath arguments.
Returns. If no data, null; if the result of the function call is an integer, an Integer; otherwise: byte[]
getData is a wrapper method around Fastpath that assumes that the function to be called returns binary data.
Parameters.
Name of the function to call.
Fastpath arguments.
Returns. A byte array that contains the result.
getID returns the OID of the function associated with the given function name. If the function name is not in the lookup table (that is: if either addFunction() or addFunctions() has not been called), then an SQLException is thrown.
Parameters.
Name of the function to get OID of.
getInteger is a wrapper method for fastpath that assumes that the function to be called returns an integer value.
Parameters.
Name of the function to call.
Fastpath arguments.
Returns. A byte array that contains the result.
Each fastpath call requires an array of arguments, the number and type being dependent on the function being called. This class implements the methods needed to provide this capability.
package org.postgresql.fastpath; public class FastpathArg { public FastpathArg(int value); public FastpathArg(byte[] bytes); public FastpathArg(byte[] buf, int off, int len); public FastpathArg(String s); } |
Constructs an argument that consists of a single integer.
Parameters.
The value that will be used as argument.
Constructs an argument that consists of an array of bytes.
Parameters.
Array of bytes to use as argument.
Constructs an argument that consists of part of an array of bytes.
Parameters.
source array
offset within array
length of data to include
Constructs an argument that consists of a String.
Parameters.
String that will be used as argument.
This class implements the large object interface to Red Hat Database. It provides the basic methods required to run the interface plus a pair of methods that provide InputStream and OutputStream classes for this object.
Refer to LargeObjectManager on how to gain access to LargeObject objects.
package org.postgresql.largeobject; public class LargeObject { // Constants public static final int SEEK_SET; public static final int SEEK_CUR; public static final int SEEK_END; // Methods public void close() throws SQLException; public int getOID(); public byte[] read(int len) throws SQLException; public void read(byte buf[], int off, int len) throws SQLException; public void write(byte buf[]) throws SQLException; public void write(byte buf[], int off, int len) throws SQLException; } |
Indicates a seek from the beginning of a file.
Indicates a seek from the current position.
Indicates a seek from the end of a file.
This method closes the object. You must not call methods of the object after this method is invoked.
Returns the OID of this LargeObject.
Read a certain amount of data from the large object, starting at the beginning, and return it as an array of bytes.
Parameters.
Number of bytes to read.
Read a certain amount of data from the large object, starting at the given offset, into the given byte array.
Parameters.
array to read bytes into
offset to start reading from
number of bytes to read
Write some data to the large object.
Parameters.
source data
Write a certain amount of data to the large object, starting at a given offset.
Parameters.
source data
offset to start writing at
number of bytes to write
This class implements the large object interface to Red Hat Database. It provides methods that allow client code to create, open, and delete large objects from the database. Opening a LOB returns an instance of org.postgresql.largeobject.LargeObject.
This class can only be created by org.postgresql.Connection. To get access to this class, use the following segment of code:
import org.postgresql.Connection; import org.postgresql.largeobject.*; Connection con; LargeObjectManager lobj; // ... code that opens a connection ... lobj = ((org.postgresql.Connection) con).getLargeObjectAPI(); |
package org.postgresql.largeobject; public class LargeObjectManager { // Constants public static final int WRITE; public static final int READ; public static final int READWRITE; // Methods public LargeObject open(int oid) throws SQLException; public LargeObject open(int oid, int mode) throws SQLException; public int create() throws SQLException; public int create(int mode) throws SQLException; public void delete(int oid) throws SQLException; public void unlink(int oid) throws SQLException; } |
This mode indicates we want to write to an object.
This mode indicates we want to read an object.
This mode is the default. It indicates we want read and write access to a large object.
Create a new LOB in the database. The access mode of the new LOB is set to READWRITE.
Returns. OID of the new LOB.
Create a new LOB in the database with the given access mode.
Parameters.
Access mode to use for the new LOB.
Returns. OID of the new LOB.
Delete the indicated LOB from the database.
Parameters.
OID of the LOB to delete.
Open the LOB indicated by the parameter oid. The access mode is set to READWRITE.
Parameters.
The OID of the LOB to open.
Returns. The LargeObject object that represents the opened LOB.
Parameters.
The OID of the LOB to open.
The access mode to use.
Returns. The LargeObject object that represents the opened LOB.
Deletes the indicated LOB from the database. It is identical to the delete method but is supplied because the equivalent C API (libpq) uses "unlink".
Red Hat Database is more extensible than most other databases and supports unique object-oriented features. One of the consequences of this is that you can have one table refer to a row in another table. For example:
test=> create table users (username name,fullname text); CREATE test=> create table server (servername name,adminuser users); CREATE test=> insert into users values ('peter','Peter Mount'); INSERT 2610132 1 test=> insert into server values ('maidast',2610132::users); INSERT 2610133 1 test=> select * from users; username|fullname --------+-------------- peter |Peter Mount (1 row) test=> select * from server; servername|adminuser ----------+--------- maidast | 2610132 (1 row) |
The above shows that we can use a table name as a field, and the row's OID value is stored in that field.
With Java, you can convert an object to a Stream as long as its class implements the java.io.Serializable interface. This process, known as Object Serialization, can be used to store complex objects in the database. If JDBC was used, you could use a Large Object to store objects. You cannot, however, perform queries on those objects.
What the org.postgresql.util.Serialize class does is provide a means of storing an object as a table. It also provides methods to retrieve that object from a table. In most cases, you do not need to access this class directly; you would use the PreparedStatement.setObject() and ResultSet.getObject() methods. Those methods check the object's class name against the tables in the database. If a match is found, it assumes that the object is a Serialized object and retrieves it from that table. As it does so, if the object contains other serialized objects, then it retrieves them, continuing on recursively.
The only time you would access this class, is to use the create() methods. These are not used by the driver, but issue one or more "create table" statements to the database, based on a Java Object or Class that you want to serialize.
If your object contains a line such as:
public int oid; |
then, when the object is retrieved from the table, it is set to the oid within the table. Then, if the object is modified and re-serialized, the existing entry is updated.
If the oid variable is not present, then when the object is serialized, it is always inserted into the table and any existing entry in the table is preserved. Setting oid to 0 before serialization will also cause the object to be inserted. This enables an object to be duplicated in the database.
package org.postgresql.util; public class Serializable { // Constructors public Serialize(Connection con, String type) throws SQLException; // Methods public Object fetch(int oid) throws SQLException; public int store(Object o) throws SQLException; // Class Methods public static void create(Connection con, Object o) throws SQLException; public static String toClassName(String name) throws SQLException; public static String toPostgreSQL(String name) throws SQLException; } |
This method creates an instance of Serialize that can be used to serialize/deserialize a Java object to or from a Red Hat Database table.
Parameters.
The database connection to use.
The database connection to use.
This method fetches the object with OID oid from the table set in the Serialize constructor call.
Parameters.
The OID of the object to fetch.
Returns. The object that corresponds to the given OID.
Stores an object into the table set in the Serialize constructor call.
If the object has an public int field called oid, then the following rules apply:
If oid is set to a value larger than 0, then oid is taken as the OID of the row in the table where the object is stored; the table will be updated.
If the value of oid is 0 then a new row will be created and the value of oid will be set in the object the OID of the new row. This enables an object's value in the database to be updatable.
If the object has no int called OID then the object is just stored. However, if the object is later retrieved, modified and then stored again, its new state will be appended to the table; old entries will not be overwritten.
Parameters.
The object to serialize.
Returns. The OID of the row object is stored in.
This method creates a table, given a Serializable Java Object. It should be used before serializing any objects.
Parameters.
The connection to the database.
The object to base the table on.
This converts a Java Class name to a Red Hat Database table, by replacing periods (.) with underscores (_). Thus, a Class name must not have any underscores in the name.
Another limitation is that the entire class name (including packages) cannot be longer than 31 characters (a limit forced by PostgreSQL).
Parameters.
The class name.
Returns. A string that contains the Red Hat Database table name.
This converts a PostgreSQL table to a Java Class name, by replacing underscores (_) with periods (.).
Parameters.
The Red Hat Database table name.
Returns. A string that contains the Java class name.
The PGobject class is used to describe specialized data types that are not included in the JDBC standards. A call to the addDatatype method of an org.postgresql.Connection object permits a class that extends PGobject to be associated with a named type. This is how the org.postgresql.geometric package operates.
ResultSet.getObject() will return a PGobject instance for any type that is not recognized and does not have its own handler. Therefore, all PostgreSQL data types are supported.
package org.postgresql.util; public class PGobject implements Serializable, Cloneable { // Constructors public PGobject(); // Methods public Object clone(); public boolean equals(Object obj); public final String getType(); public String getValue(); public final void setType(String type); public void setValue(String value) throws SQLException; public String toString(); } |
Creates a new instance of PGobject.
Creates a new PGobject object that is exactly the same as this one.
Compares the current PGobject object with another PGobject object.
Parameters.
object to compare with
Returns the name of the type that this PGobject represents.
Returns the value of the type that this PGobject represents. This method should be overridden by subclasses.
Sets the type of the object.
Parameters.
The name.
Sets the value of this PGobject. This method should be overridden by subclasses.
Parameters.
String representation of this object's value.
Returns the value of this object in string form.
The PGmoney class handles the Red Hat Database money data type.
package org.postgresql.util; public class PGmoney extends PGobject implements Serializable, Cloneable { // Variables public double val; // Constructors public PGmoney(); public PGmoney(double val); public PGmoney(String value) throws SQLException; // Methods public void setValue(String s) throws SQLException; public boolean equals(Object obj); public Object clone(); public String getValue(); } |
The monetary amount that the a PGmoney object represents.
Creates a new PGmoney object. The value of val is undefined.
Creates a new PGmoney object with val set to value.
Parameters.
The amount of money the new PGmoney object should represent.
Creates a new PGmoney object using the Red Hat Database syntax for the money data type.
Parameters.
The definition in the Red Hat Database money syntax.
Creates a new PGmoney object that is exactly the same as this one.
Compares the current PGmoney object with another PGmoney object.
Parameters.
The object to compare with.
Returns. True if the two PGmoney objects are identical.
Returns the definition of the PGmoney object in the Red Hat Database money syntax.
Returns. The PGmoney definition in the syntax expected by Red Hat Database.
This method sets the value of this PGmoney object. The Red Hat Database money syntax must be used.
Throws: SQLException on conversion failure.
The PGtokenizer class is used to tokenize the text output of Red Hat Database. It is used by the geometric classes. Any custom handler classes that need to parse output from Red Hat Database will find PGtokenizer useful.
package org.postgresql.util; public class PGtokenizer { // Constructors public PGtokenizer(String string, char delim); // Methods public int getSize(); public String getToken(int n); public void remove(String l, String t); public void removeAngle(); public void removeBox(); public void removePara(); public int tokenize(String string, char delim); public PGtokenizer tokenizeToken(int n, char delim); // Class methods public static String remove(String s, String l, String t); public static String removeAngle(String s); public static String removeBox(String s); public static String removePara(String s); } |
Creates a new tokenizer that will tokenize the supplied string using delim as token separator.
Parameters.
The string to tokenize.
The character that separates tokens.
Returns the number of tokens that the string was parsed into.
getToken returns the n'th available token. n is between 0 and getSize() - 1.
Parameters.
Token to get.
Returns. The n'th token.
Removes the String l from the beginning of all tokens and the String t from the end of all tokens.
Parameters.
Leading string to remove.
Trailing string to remove.
Removes '<' from the beginning of all tokens and '>' from the end of all tokens.
Removes '[' from the beginning of all tokens and ']' from the end of all tokens.
Removes '(' from the beginning of all tokens and ')' from the end of all tokens.
Resets the tokenizer with a new string and delimiter.
Parameters.
The string to tokenize.
Character to recognize as the delimiter.
Returns. The number of tokens created.
Returns a new tokenizer based on the n'th token of the current tokenizer, where 0 <= n <= getSize() - 1. This method is useful for parsing nested tokens.
Parameters.
The index of the token to tokenize.
Character to recognize as the delimiter.
Returns. A new PGtokenizer.
Removes the given leading and trailing strings from another string.
Parameters.
The String to be trimmed.
The leading String to remove.
The trailing String to remove.
Returns. A new String based on s but without leading and trailing strings.
Removes '<' from the beginning of s and '>' from the end of s.
Parameters.
The String to trim angled brackets from.
Returns. A new String based on s but with leading '<' removed and trailing '>' removed.
Removes '[' from the beginning of s and ']' from the end of s.
Parameters.
The String to trim square brackets from.
Returns. A new String based on s but with leading '[' removed and trailing ']' removed.
Removes '(' from the beginning of s and ')' from the end of s.
Parameters.
The String to trim parentheses from.
Returns. A new String based on s but with leading '(' removed and trailing ')' removed.
UnixCrypt provides the ability to encrypt passwords that are to be sent over the network stream for user authentication. It contains static methods to encrypt passwords and to compare passwords with Unix-encrypted ones.
package org.postgresql.util; public class UnixCrypt { // Class Methods public static final String crypt(String original); public static final String crypt(String salt, String original); public static final boolean matches(String encrypted, String entered); } |
Returns an encrypted version of the original parameter. This method generates and uses a random salt using the java.util.Random class.
Parameters.
The text (password) to encrypt.
Returns. The encrypted version of the original parameter.
Returns an encrypted version of the original parameter. This method uses a user-supplied salt value.
Parameters.
A two-character string representing the salt that is used to iterate the encryption engine in many different ways. If you are generating a new encryption, this should be set to a random value.
The text (password) to encrypt.
Returns. The encrypted version of the original parameter.
Checks that enteredPassword encrypts to encryptedPassword.
Parameters.
The encrypted text. The first two characters are assumed to be the salt. This string would be the same one as found in a Unix /etc/passwd file.
The text plain text that is being checked.
Returns. Returns true when enteredPassword encrypts to encryptedPassword; false otherwise
This implements a version of java.awt.Point, except it uses double variables to represent the coordinates. PGpoint maps to the point data type in Red Hat Database.
package org.postgresql.geometric; public class PGpoint extends PGobject implements Serializable, Cloneable { // Variables public double x; public double y; // Constructors public PGpoint(); public PGpoint(double x, double y); public PGpoint(String value) throws SQLException; // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void move(int x, int y); public void move(double x, double y); public void setLocation(int x, int y); public void setLocation(Point p); public void setValue(String s) throws SQLException; public void translate(int x, int y); public void translate(double x, double y); } |
The X coordinate of the point.
The Y coordinate of the point.
Creates a new PGpoint object. The x and y fields are undefined.
Parameters.
The X coordinate.
The Y coordinate.
Parameters.
The definition of this point in Red Hat Database's syntax.
Creates a new PGpoint object that is exactly the same as this one.
Compare the current PGpoint object with another PGpoint object.
Parameters.
The object to compare with.
Returns. Returns true if the two points are identical; false otherwise.
Returns the definition of the PGpoint in Red Hat Database point syntax.
Returns. The PGpoint in the syntax expected by Red Hat Database.
Moves the point to the supplied coordinates.
Parameters.
The new X coordinate.
The new Y coordinate.
Moves the point to the supplied coordinates.
Parameters.
The new X coordinate.
The new Y coordinate.
Moves the point to the supplied coordinates. This method is the same as move(int, int).
Parameters.
The new X coordinate.
The new Y coordinate.
Moves the point to the coordinate defined by the supplied Point.
Parameters.
The point to move to.
This method sets the X and Y coordinates of this PGpoint. The Red Hat Database point syntax must be used.
Parameters.
The definition of this point in the Red Hat Database point syntax.
Throws: SQLException on conversion failure.
Translates the point by the given amount. The new position of the PGpoint p at (x, y) will be (x + dx, y + dy).
Parameters.
The integer amount to move on the X axis.
The integer amount to move on the Y axis.
Translates the point by the given amount. The new position of the PGpoint p at (x, y) will be (x + dx, y + dy).
Parameters.
The double amount to move on the X axis.
The double amount to move on the Y axis.
This implements the lseg data type. lseg represents a finite line or line segment; the line does not extend beyond its two endpoints.
package org.postgresql.geometric; public class PGlseg extends PGobject implements Serializable, Cloneable { // Variables public PGpoint[] point; // Constructors public PGlseg(); public PGlseg(double x1, double y1, double x2, double y2); public PGlseg(PGpoint p1, PGpoint p2); public PGlseg(String s) throws SQLException; // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void setValue(String s) throws SQLException; } |
The two end-points of the line segment.
Creates a new PGlseg object. The two points are undefined.
Creates a new PGlseg object with endpoints (x1, y1) and (x2, y2).
Parameters.
The X coordinate for the first end-point.
The Y coordinate for the first end-point.
The X coordinate for the second end-point.
The Y coordinate for the second end-point.
Creates a new PGlseg object with endpoints p1 and p2.
Parameters.
The first end-point.
The second end-point.
Creates a new PGlseg object using the Red Hat Database syntax for the lseg data type.
Parameters.
The definition of the circle in Red Hat Database syntax.
Throws: SQLException on conversion failure.
Creates a new PGlseg object that is exactly the same as this one.
Compares the current PGlseg with another PGlseg object.
Parameters.
Object to compare with.
Returns. Returns true if the two PGlseg objects are identical; false otherwise.
Returns the definition of the PGlseg in Red Hat Database lseg syntax.
Returns. The PGlseg in the syntax expected by Red Hat Database.
This method sets the two end-points. The Red Hat Database lseg definition syntax must be used.
Parameters.
The definition of the line segment in Red Hat Database syntax.
Throws: SQLException on conversion failure.
This implements an infinite line which is defined by two points. The line data type exists in the backend but is currently unimplemented. This class is included for completeness.
package org.postgresql.geometric; public class PGline extends PGobject implements Serializable, Cloneable { // Variables public PGpoint[] point; // Constructors public PGline(); public PGline(double x1, double y1, double x2, double y2); public PGline(PGpoint p1, PGpoint p2); public PGline(String s) throws SQLException; // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void setValue(String s) throws SQLException; } |
The two end-points that define the line.
Creates a new PGline object. The two points are undefined.
Creates a new PGlseg object with endpoints (x1, y1) and (x2, y2).
Parameters.
The X coordinate for the first point.
The Y coordinate for the first point.
The X coordinate for the second point.
The Y coordinate for the second point.
Creates a new PGlseg object with the points p1 and p2.
Parameters.
The first point.
The second point.
Creates a new PGlseg object using the Red Hat Database syntax for the lseg data type.
Parameters.
The definition of the circle in Red Hat Database syntax.
Throws: SQLException on conversion failure.
Creates a new PGline object that is exactly the same as this one.
Compares the current PGline with another PGline object.
Parameters.
Object to compare with.
Returns. Returns true if the two PGline objects are identical; false otherwise.
Returns the definition of the PGline in Red Hat Database line syntax.
Returns. The PGline in the syntax expected by Red Hat Database.
This method sets the two end-points of this PGline. The Red Hat Database line definition syntax must be used.
Parameters.
The definition of the line segment in Red Hat Database syntax.
Throws: SQLException on conversion failure.
The PGbox class represents Red Hat Database's box data type. A box is represented by a pair of points, the opposite corners of the box.
package org.postgresql.geometric; public class PGbox extends PGobject implements Serializable, Cloneable { // Variables public PGpoint[] point; // Constructors public PGbox(double x1, double y1, double x2, double y2); // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void setValue(String value) throws SQLException; } |
The two corner points of the box.
Creates a new PGbox object. The values of the two corner points are undefined.
Creates a new PGbox object whose corner points are (x1, y1) and (x2, y2).
Parameters.
The X coordinate for the first point.
The Y coordinate for the first point.
The X coordinate for the second point.
The Y coordinate for the second point.
Creates a new PGbox object whose corner points are p1 and p2.
Parameters.
The first point.
The second point.
Creates a new PGbox object whose definition is given in the Red Hat Database syntax.
Parameters.
The definition of the box in Red Hat Database syntax.
Throws: SQLException if the definition is invalid.
Creates a new PGbox object that is exactly the same as this one.
Compares the current PGbox with another PGbox object.
Parameters.
Object to compare with.
Returns. Returns true if the two PGbox objects are identical; false otherwise.
Returns the definition of the PGbox in Red Hat Database syntax.
Returns. The PGbox in the syntax expected by Red Hat Database.
This method sets the position of the two corner points of this PGbox object. The Red Hat Database line definition syntax must be used.
Parameters.
The PGbox definition in Red Hat Database syntax.
Throws: SQLException thrown if value is invalid.
The PGbox class represents Red Hat Database's polygon data type.
package org.postgresql.geometric; public class PGpolygon extends PGobject implements Serializable, Cloneable { // Variables public PGpoint[] points; // Constructors public PGpolygon(); public PGpolygon(PGpoint points[]); public PGpolygon(String s) throws SQLException; // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void setValue(String s) throws SQLException; } |
The points defining the polygon.
Creates a new PGpolygon. The points making up the polygon are undefined.
Creates a PGpolygon using an array of PGpooints.
Parameters.
The points defining the polygon.
Creates a new PGpolygon using the Red Hat Database syntax for the polygon data type.
Parameters.
Definition of the polygon in Red Hat Database polygon syntax.
Throws: SQLException on conversion failure.
Creates a new PGpolygon object that is exactly the same as this one.
Compares the current PGpolygon object with another PGpolygon object
Parameters.
The object to compare with.
Returns. True if the two polygons are identical.
Returns the definition of the PGpolygon in Red Hat Database syntax.
Returns. The PGpolygon definition in the syntax expected by Red Hat Database.
Sets the points that make up this PGpolygon. The Red Hat Database polygon syntax must be used.
Parameters.
Definition of the polygon in Red Hat Database polygon syntax.
Throws: SQLException on conversion failure.
PGcircle represents Red Hat Database's circle data type. A circle consists of a center point and a radius.
package org.postgresql.geometric; public class PGcircle extends PGobject implements Serializable, Cloneable { // Variables public PGpoint center; public double radius; // Constructors public PGcircle(); public PGcircle(double x, double y, double r); public PGcircle(PGpoint c, double r); public PGcircle(String s) throws SQLException; // Methods public Object clone(); public boolean equals(Object obj); public String getValue(); public void setValue(String s) throws SQLException; } |
The center point of the circle.
The radius of the circle.
Creates a new PGcircle object. The center and radius are undefined.
Creates a new PGcircle object with center (x, y) and radius r.
Parameters.
The X coordinate of the center.
The Y coordinate of the center.
The radius.
Creates a new PGcircle object with center c and radius r.
Parameters.
PGpoint describing the circle's center.
The radius.
Creates a new PGcircle using the Red Hat Database syntax for the circle data type.
Parameters.
Definition of the circle in Red Hat Database circle syntax.
Creates a new PGcircle object that is exactly the same as this one.
Compares the current PGcircle object with another PGcircle object.
Parameters.
Object to compare with.
Returns. True if the two PGcircle objects are identical.
Returns the definition of the PGcircle in Red Hat Database syntax.
Returns. The PGcircle definition in the syntax expected by Red Hat Database.
Sets the center and radius of this PGcircle. The Red Hat Database circle syntax must be used.
Parameters.
The definition of the circle in Red Hat Database circle syntax.
Throws: SQLException on conversion failure.
PGpath implements a path, a line with multiple segments. The path may or may not be closed.
package org.postgresql.geometric; public class PGpath extends PGobject implements Serializable, Cloneable { // Variables public boolean open; public PGpoint[] points; // Constructors public PGpath(); public PGpath(PGpoint points[], boolean open); public PGpath(String s) throws SQLException; // Methods public Object clone(); public void closePath(); public boolean equals(Object obj); public String getValue(); public boolean isClosed(); public boolean isOpen(); public void openPath(); public void setValue(String s) throws SQLException; } |
True if the path is open, false if closed.
The points that define a path.
Creates a new PGpath object. The number of points and their values are undefined.
Creates a new PGpath object based on the given points.
Parameters.
The PGpoints that define the path.
True if the path is open, false if closed.
Creates a new PGpath object using the Red Hat Database syntax for the path data type.
Parameters.
Definition of the path in PostgreSQL's syntax.
Throws:
SQLException on conversion failure.
Creates a new PGpath object that is exactly the same as this one.
Marks the path as closed.
Compares the current PGpath with another PGpath object.
Parameters.
Object to compare with.
Returns. True if the two paths are identical.
Returns the definition of the PGpath in Red Hat Database path syntax.
Returns true if the path is closed.
Returns true if the path is open.
Marks the path as open.
Sets the points of this PGpath. The Red Hat Database path syntax must be used.
Parameters.
Definition of the path in Red Hat Database syntax.
Throws:
SQLException on conversion failure.