/** * @param s definition of the line segment in PostgreSQL's syntax. * @throws SQLException on conversion failure */ public PGlseg(String s) throws SQLException { this(); setValue(s); }
/** * @param s definition of the path in PostgreSQL's syntax. * @throws SQLException on conversion failure */ public PGpath(String s) throws SQLException { this(); setValue(s); }
/** * Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this. * * @param p Point to move to * @see java.awt.Point */ public void setLocation(Point p) { setLocation(p.x, p.y); }
/** * This is called mainly from the other geometric types, when a point is embedded within their * definition. * * @param value Definition of this point in PostgreSQL's syntax * @throws SQLException if something goes wrong */ public PGpoint(String value) throws SQLException { this(); setValue(value); }
/** * @param s definition of the polygon in PostgreSQL's syntax. * @throws SQLException on conversion failure */ public PGpolygon(String s) throws SQLException { this(); setValue(s); }
/** * @param s definition of the circle in PostgreSQL's syntax. * @throws SQLException on conversion failure */ public PGcircle(String s) throws SQLException { this(); setValue(s); }
public int hashCode() { // This relies on the behaviour of point's hashcode being an exclusive-OR of // its X and Y components; we end up with an exclusive-OR of the two X and // two Y components, which is equal whenever equals() would return true // since xor is commutative. return point[0].hashCode() ^ point[1].hashCode(); }
/** * @param obj Object to compare with * @return true if the two line segments are identical */ public boolean equals(Object obj) { if (obj instanceof PGlseg) { 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])); } return false; }
/** * Required constructor. */ public PGbox() { setType("box"); }
/** * Required by the driver. */ public PGpoint() { setType("point"); }
/** * required by the driver. */ public PGlseg() { setType("lseg"); }
/** * This constructor is used by the driver. */ public PGcircle() { setType("circle"); }
/** * Moves the point to the supplied coordinates. refer to java.awt.Point for description of this. * * @param x integer coordinate * @param y integer coordinate * @see java.awt.Point */ public void setLocation(int x, int y) { move((double) x, (double) y); }
public void toBytes(byte[] bytes, int offset) { point[0].toBytes(bytes, offset); point[1].toBytes(bytes, offset + point[0].lengthInBytes()); } }
public int hashCode() { // XXX not very good.. int hash = 0; for (int i = 0; i < points.length && i < 5; ++i) { hash = hash ^ points[i].hashCode(); } return hash; }
/** * Moves the point to the supplied coordinates. * * @param x integer coordinate * @param y integer coordinate */ public void move(int x, int y) { setLocation(x, y); }
/** * @param obj Object to compare with * @return true if the two circles are identical */ public boolean equals(Object obj) { if (obj instanceof PGcircle) { PGcircle p = (PGcircle) obj; return p.center.equals(center) && p.radius == radius; } return false; }
public int hashCode() { // XXX not very good.. int hash = 0; for (int i = 0; i < points.length && i < 5; ++i) { hash = hash ^ points[i].hashCode(); } return hash; }