package postgresql.geometric; import java.io.*; import java.sql.*; import postgresql.util.*; /** * This implements the polygon datatype within PostgreSQL. */ public class PGpolygon extends PGobject implements Serializable,Cloneable { /** * The points defining the polygon */ public PGpoint points[]; /** * Creates a polygon using an array of PGpoints * * @param points the points defining the polygon */ public PGpolygon(PGpoint[] points) { this(); this.points = points; } /** * @param s definition of the circle in PostgreSQL's syntax. * @exception SQLException on conversion failure */ public PGpolygon(String s) throws SQLException { this(); setValue(s); } /** * Required by the driver */ public PGpolygon() { setType("polygon"); } /** * @param s Definition of the polygon in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s),','); int npoints = t.getSize(); points = new PGpoint[npoints]; for(int p=0;p0) b.append(","); b.append(points[p].toString()); } b.append(")"); return b.toString(); } }