1
/*-------------------------------------------------------------------------
4
* This implements a lseg (line segment) consisting of two points
6
* Copyright (c) 2003, PostgreSQL Global Development Group
9
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGlseg.java,v 1.5 2003/09/13 04:02:15 barry Exp $
11
*-------------------------------------------------------------------------
13
package org.postgresql.geometric;
15
import org.postgresql.util.PGobject;
16
import org.postgresql.util.PGtokenizer;
17
import org.postgresql.util.PSQLException;
18
import org.postgresql.util.PSQLState;
20
import java.io.Serializable;
21
import java.sql.SQLException;
23
public class PGlseg extends PGobject implements Serializable, Cloneable
26
* These are the two points.
28
public PGpoint point[] = new PGpoint[2];
31
* @param x1 coordinate for first point
32
* @param y1 coordinate for first point
33
* @param x2 coordinate for second point
34
* @param y2 coordinate for second point
36
public PGlseg(double x1, double y1, double x2, double y2)
38
this(new PGpoint(x1, y1), new PGpoint(x2, y2));
42
* @param p1 first point
43
* @param p2 second point
45
public PGlseg(PGpoint p1, PGpoint p2)
53
* @param s definition of the circle in PostgreSQL's syntax.
54
* @exception SQLException on conversion failure
56
public PGlseg(String s) throws SQLException
63
* reuired by the driver
71
* @param s Definition of the line segment in PostgreSQL's syntax
72
* @exception SQLException on conversion failure
74
public void setValue(String s) throws SQLException
76
PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
78
throw new PSQLException("postgresql.geo.lseg", PSQLState.DATA_TYPE_MISMATCH);
80
point[0] = new PGpoint(t.getToken(0));
81
point[1] = new PGpoint(t.getToken(1));
85
* @param obj Object to compare with
86
* @return true if the two boxes are identical
88
public boolean equals(Object obj)
90
if (obj instanceof PGlseg)
92
PGlseg p = (PGlseg)obj;
93
return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) ||
94
(p.point[0].equals(point[1]) && p.point[1].equals(point[0]));
100
* This must be overidden to allow the object to be cloned
102
public Object clone()
104
return new PGlseg((PGpoint)point[0].clone(), (PGpoint)point[1].clone());
108
* @return the PGlseg in the syntax expected by org.postgresql
110
public String getValue()
112
return "[" + point[0] + "," + point[1] + "]";