1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-06 19:59:18 +03:00
Barry Lind 509a9cd3f9 More SQLState updates from Kim Ho at Redhat.
Also a patch from Kris Jurka to correctly report SQLState support.

 Modified Files:
 	jdbc/org/postgresql/Driver.java.in
 	jdbc/org/postgresql/core/QueryExecutor.java
 	jdbc/org/postgresql/fastpath/Fastpath.java
 	jdbc/org/postgresql/geometric/PGbox.java
 	jdbc/org/postgresql/geometric/PGcircle.java
 	jdbc/org/postgresql/geometric/PGline.java
 	jdbc/org/postgresql/geometric/PGlseg.java
 	jdbc/org/postgresql/geometric/PGpath.java
 	jdbc/org/postgresql/geometric/PGpoint.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc2/Array.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
 	jdbc/org/postgresql/util/PGmoney.java
 	jdbc/org/postgresql/util/PSQLState.java
2003-09-13 04:02:16 +00:00

120 lines
2.8 KiB
Java

/*-------------------------------------------------------------------------
*
* PGbox.java
* This represents the box datatype within org.postgresql.
*
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGbox.java,v 1.5 2003/09/13 04:02:14 barry Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.geometric;
import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.io.Serializable;
import java.sql.SQLException;
public class PGbox extends PGobject implements Serializable, Cloneable
{
/*
* These are the two points.
*/
public PGpoint point[] = new PGpoint[2];
/*
* @param x1 first x coordinate
* @param y1 first y coordinate
* @param x2 second x coordinate
* @param y2 second y coordinate
*/
public PGbox(double x1, double y1, double x2, double y2)
{
this();
this.point[0] = new PGpoint(x1, y1);
this.point[1] = new PGpoint(x2, y2);
}
/*
* @param p1 first point
* @param p2 second point
*/
public PGbox(PGpoint p1, PGpoint p2)
{
this();
this.point[0] = p1;
this.point[1] = p2;
}
/*
* @param s Box definition in PostgreSQL syntax
* @exception SQLException if definition is invalid
*/
public PGbox(String s) throws SQLException
{
this();
setValue(s);
}
/*
* Required constructor
*/
public PGbox()
{
setType("box");
}
/*
* This method sets the value of this object. It should be overidden,
* but still called by subclasses.
*
* @param value a string representation of the value of the object
* @exception SQLException thrown if value is invalid for this type
*/
public void setValue(String value) throws SQLException
{
PGtokenizer t = new PGtokenizer(value, ',');
if (t.getSize() != 2)
throw new PSQLException("postgresql.geo.box", PSQLState.DATA_TYPE_MISMATCH, value);
point[0] = new PGpoint(t.getToken(0));
point[1] = new PGpoint(t.getToken(1));
}
/*
* @param obj Object to compare with
* @return true if the two boxes are identical
*/
public boolean equals(Object obj)
{
if (obj instanceof PGbox)
{
PGbox p = (PGbox)obj;
return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) ||
(p.point[0].equals(point[1]) && p.point[1].equals(point[0]));
}
return false;
}
/*
* This must be overidden to allow the object to be cloned
*/
public Object clone()
{
return new PGbox((PGpoint)point[0].clone(), (PGpoint)point[1].clone());
}
/*
* @return the PGbox in the syntax expected by org.postgresql
*/
public String getValue()
{
return point[0].toString() + "," + point[1].toString();
}
}