1
/*-------------------------------------------------------------------------
4
* This implements the polygon datatype within PostgreSQL.
6
* Copyright (c) 2003, PostgreSQL Global Development Group
9
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpolygon.java,v 1.5 2003/05/29 04:39:48 barry Exp $
11
*-------------------------------------------------------------------------
13
package org.postgresql.geometric;
15
import org.postgresql.util.PGobject;
16
import org.postgresql.util.PGtokenizer;
17
import java.io.Serializable;
18
import java.sql.SQLException;
20
public class PGpolygon extends PGobject implements Serializable, Cloneable
23
* The points defining the polygon
25
public PGpoint points[];
28
* Creates a polygon using an array of PGpoints
30
* @param points the points defining the polygon
32
public PGpolygon(PGpoint[] points)
39
* @param s definition of the circle in PostgreSQL's syntax.
40
* @exception SQLException on conversion failure
42
public PGpolygon(String s) throws SQLException
49
* Required by the driver
57
* @param s Definition of the polygon in PostgreSQL's syntax
58
* @exception SQLException on conversion failure
60
public void setValue(String s) throws SQLException
62
PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
63
int npoints = t.getSize();
64
points = new PGpoint[npoints];
65
for (int p = 0;p < npoints;p++)
66
points[p] = new PGpoint(t.getToken(p));
70
* @param obj Object to compare with
71
* @return true if the two boxes are identical
73
public boolean equals(Object obj)
75
if (obj instanceof PGpolygon)
77
PGpolygon p = (PGpolygon)obj;
79
if (p.points.length != points.length)
82
for (int i = 0;i < points.length;i++)
83
if (!points[i].equals(p.points[i]))
92
* This must be overidden to allow the object to be cloned
96
PGpoint ary[] = new PGpoint[points.length];
97
for (int i = 0;i < points.length;i++)
98
ary[i] = (PGpoint)points[i].clone();
99
return new PGpolygon(ary);
103
* @return the PGpolygon in the syntax expected by org.postgresql
105
public String getValue()
107
StringBuffer b = new StringBuffer();
109
for (int p = 0;p < points.length;p++)
113
b.append(points[p].toString());