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/PGlseg.java | |
parent | e9cd0f2e6bfec624de8d4f15a4c880b583008ac0 (diff) |
Bring in Peter's changes...finally :(
Diffstat (limited to 'src/interfaces/jdbc/postgresql/PGlseg.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/PGlseg.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/interfaces/jdbc/postgresql/PGlseg.java b/src/interfaces/jdbc/postgresql/PGlseg.java new file mode 100644 index 00000000000..d073b46b20b --- /dev/null +++ b/src/interfaces/jdbc/postgresql/PGlseg.java @@ -0,0 +1,58 @@ +/** + * + * This implements a lseg (line segment) consisting of two points + * + */ + +package postgresql; + +import java.io.*; +import java.sql.*; + +public class PGlseg implements Serializable +{ + /** + * These are the two points. + */ + public PGpoint point[] = new PGpoint[2]; + + public PGlseg(double x1,double y1,double x2,double y2) + { + this.point[0] = new PGpoint(x1,y1); + this.point[1] = new PGpoint(x2,y2); + } + + public PGlseg(PGpoint p1,PGpoint p2) + { + this.point[0] = p1; + this.point[1] = p2; + } + + /** + * This constructor is used by the driver. + */ + public PGlseg(String s) throws SQLException + { + PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s),','); + if(t.getSize() != 2) + throw new SQLException("conversion of lseg failed - "+s); + + point[0] = new PGpoint(t.getToken(0)); + point[1] = new PGpoint(t.getToken(1)); + } + + public boolean equals(Object obj) + { + PGlseg p = (PGlseg)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])); + } + + /** + * This returns the lseg in the syntax expected by postgresql + */ + public String toString() + { + return "["+point[0]+","+point[1]+"]"; + } +} |