diff options
author | Marc G. Fournier <scrappy@hub.org> | 1997-09-20 02:21:25 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1997-09-20 02:21:25 +0000 |
commit | fa67a247cf66ea86f6fcc773c27cfd4698d2405a (patch) | |
tree | 880c11f644273a976ad8790a95a94abf90b2b2e2 /src/interfaces/jdbc/postgresql/PGcircle.java | |
parent | e9cd0f2e6bfec624de8d4f15a4c880b583008ac0 (diff) |
Bring in Peter's changes...finally :(
Diffstat (limited to 'src/interfaces/jdbc/postgresql/PGcircle.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/PGcircle.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/interfaces/jdbc/postgresql/PGcircle.java b/src/interfaces/jdbc/postgresql/PGcircle.java new file mode 100644 index 00000000000..543a0a71c91 --- /dev/null +++ b/src/interfaces/jdbc/postgresql/PGcircle.java @@ -0,0 +1,72 @@ +/** + * + * This implements a circle consisting of a point and a radius + * + */ + +package postgresql; + +import java.io.*; +import java.sql.*; + +public class PGcircle implements Serializable +{ + /** + * This is the centre point + */ + public PGpoint center; + + /** + * This is the radius + */ + double radius; + + public PGcircle(double x,double y,double r) + { + this.center = new PGpoint(x,y); + this.radius = r; + } + + public PGcircle(PGpoint c,double r) + { + this.center = c; + this.radius = r; + } + + public PGcircle(PGcircle c) + { + this.center = new PGpoint(c.center); + this.radius = c.radius; + } + + /** + * This constructor is used by the driver. + */ + public PGcircle(String s) throws SQLException + { + PGtokenizer t = new PGtokenizer(PGtokenizer.removeAngle(s),','); + if(t.getSize() != 2) + throw new SQLException("conversion of circle failed - "+s); + + try { + center = new PGpoint(t.getToken(0)); + radius = Double.valueOf(t.getToken(1)).doubleValue(); + } catch(NumberFormatException e) { + throw new SQLException("conversion of circle failed - "+s+" - +"+e.toString()); + } + } + + public boolean equals(Object obj) + { + PGcircle p = (PGcircle)obj; + return p.center.equals(center) && p.radius==radius; + } + + /** + * This returns the circle in the syntax expected by postgresql + */ + public String toString() + { + return "<"+center+","+radius+">"; + } +} |