Package org.postgresql.geometric
Class PGpoint
java.lang.Object
org.postgresql.util.PGobject
org.postgresql.geometric.PGpoint
- All Implemented Interfaces:
Serializable,Cloneable,PGBinaryObject
It maps to the point datatype in org.postgresql.
This implements a version of java.awt.Point, except it uses double to represent the coordinates.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanTrue if the point representsnull::point.doubleThe X coordinate of the point.doubleThe Y coordinate of the point. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()This must be overridden to allow the object to be cloned.booleanThis must be overridden to allow comparisons of objects.@Nullable StringgetValue()This must be overridden, to return the value of the object, in the form required by org.postgresql.inthashCode()Compute hash.intThis method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.voidmove(double x, double y) Moves the point to the supplied coordinates.voidmove(int x, int y) Moves the point to the supplied coordinates.voidsetByteValue(byte[] b, int offset) This method is called to set the value of this object.voidsetLocation(int x, int y) Moves the point to the supplied coordinates.voidsetLocation(Point p) Deprecated.voidThis method sets the value of this object.voidtoBytes(byte[] b, int offset) Populate the byte array with PGpoint in the binary syntax expected by org.postgresql.voidtranslate(double x, double y) Translate the point by the supplied amount.voidtranslate(int x, int y) Translate the point by the supplied amount.
-
Field Details
-
x
public double xThe X coordinate of the point. -
y
public double yThe Y coordinate of the point. -
isNull
public boolean isNullTrue if the point representsnull::point.
-
-
Constructor Details
-
PGpoint
public PGpoint(double x, double y) - Parameters:
x- coordinatey- coordinate
-
PGpoint
This is called mainly from the other geometric types, when a point is embedded within their definition.- Parameters:
value- Definition of this point in PostgreSQL's syntax- Throws:
SQLException- if something goes wrong
-
PGpoint
public PGpoint()Required by the driver.
-
-
Method Details
-
setValue
Description copied from class:PGobjectThis method sets the value of this object. It must be overridden.- Overrides:
setValuein classPGobject- Parameters:
s- Definition of this point in PostgreSQL's syntax- Throws:
SQLException- on conversion failure
-
setByteValue
public void setByteValue(byte[] b, int offset) Description copied from interface:PGBinaryObjectThis method is called to set the value of this object.- Specified by:
setByteValuein interfacePGBinaryObject- Parameters:
b- Definition of this point in PostgreSQL's binary syntaxoffset- the offset in the byte array where object data starts
-
equals
Description copied from class:PGobjectThis must be overridden to allow comparisons of objects. -
hashCode
public int hashCode()Description copied from class:PGobjectCompute hash. As equals() use only value. Return the same hash for the same value.- Overrides:
hashCodein classPGobject- Returns:
- Value hashcode, 0 if value is null
Objects.hashCode(Object)
-
getValue
Description copied from class:PGobjectThis must be overridden, to return the value of the object, in the form required by org.postgresql. -
lengthInBytes
public int lengthInBytes()Description copied from interface:PGBinaryObjectThis method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.- Specified by:
lengthInBytesin interfacePGBinaryObject- Returns:
- the number of bytes needed to store this object
-
toBytes
public void toBytes(byte[] b, int offset) Populate the byte array with PGpoint in the binary syntax expected by org.postgresql.- Specified by:
toBytesin interfacePGBinaryObject- Parameters:
b- the array to store the value, it is guaranteed to be at lestPGBinaryObject.lengthInBytes()in size.offset- the offset in the byte array where object must be stored
-
translate
public void translate(int x, int y) Translate the point by the supplied amount.- Parameters:
x- integer amount to add on the x axisy- integer amount to add on the y axis
-
translate
public void translate(double x, double y) Translate the point by the supplied amount.- Parameters:
x- double amount to add on the x axisy- double amount to add on the y axis
-
move
public void move(int x, int y) Moves the point to the supplied coordinates.- Parameters:
x- integer coordinatey- integer coordinate
-
move
public void move(double x, double y) Moves the point to the supplied coordinates.- Parameters:
x- double coordinatey- double coordinate
-
setLocation
public void setLocation(int x, int y) Moves the point to the supplied coordinates. refer to java.awt.Point for description of this.- Parameters:
x- integer coordinatey- integer coordinate- See Also:
-
setLocation
Deprecated.Will be removed for avoiding a dependency to thejava.desktopmodule.Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this.- Parameters:
p- Point to move to- See Also:
-
clone
Description copied from class:PGobjectThis must be overridden to allow the object to be cloned.- Overrides:
clonein classPGobject- Throws:
CloneNotSupportedException
-
java.desktopmodule.