Top Description Fields Constructors Methods
org.postgresql.geometric

public Class PGpoint

extends PGobject
implements PGBinaryObject, Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable, org.postgresql.util.PGBinaryObject
Imports
org.postgresql.util.ByteConverter, .GT, .PGBinaryObject, .PGobject, .PGtokenizer, .PSQLException, .PSQLState, org.checkerframework.checker.nullness.qual.Nullable, java.awt.Point, java.io.Serializable, java.sql.SQLException

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.

Field Summary

Modifier and TypeField and Description
public boolean
isNull

True if the point represents null::point.

public double
x

The X coordinate of the point.

public double
y

The Y coordinate of the point.

Inherited from org.postgresql.util.PGobject:
typevalue

Constructor Summary

AccessConstructor and Description
public
PGpoint(double
coordinate
x
,
double
coordinate
y
)

public
PGpoint(String
Definition of this point in PostgreSQL's syntax
value
)

This is called mainly from the other geometric types, when a point is embedded within their definition.

public
PGpoint()

Required by the driver.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides org.postgresql.util.PGobject.clone.

This must be overridden to allow the object to be cloned.

public boolean

Returns:

true if the two points are identical
equals
(@Nullable Object
Object to compare with
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public @Nullable String

Returns:

the PGpoint in the syntax expected by org.postgresql
getValue
()

Overrides org.postgresql.util.PGobject.getValue.

This must be overridden, to return the value of the object, in the form required by org.postgresql.

public int
public int
lengthInBytes()

Implements org.postgresql.util.PGBinaryObject.lengthInBytes.

This method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.

public void
move(int
integer coordinate
x
,
int
integer coordinate
y
)

Moves the point to the supplied coordinates.

public void
move(double
double coordinate
x
,
double
double coordinate
y
)

Moves the point to the supplied coordinates.

public void
setByteValue(byte[]
Definition of this point in PostgreSQL's binary syntax
b
,
int
the offset in the byte array where object data starts
offset
)

Implements org.postgresql.util.PGBinaryObject.setByteValue.

This method is called to set the value of this object.

public void
setLocation(int
integer coordinate
x
,
int
integer coordinate
y
)

Moves the point to the supplied coordinates.

public void
setLocation(Point
Point to move to
p
)
Deprecated Will be removed for avoiding a dependency to the java.desktop module.

Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this.

public void
setValue(@Nullable String
Definition of this point in PostgreSQL's syntax
s
)

public void
toBytes(byte[]
the array to store the value, it is guaranteed to be at lest lengthInBytes in size.
b
,
int
the offset in the byte array where object must be stored
offset
)

Implements org.postgresql.util.PGBinaryObject.toBytes.

Populate the byte array with PGpoint in the binary syntax expected by org.postgresql.

public void
translate(int
integer amount to add on the x axis
x
,
int
integer amount to add on the y axis
y
)

Translate the point by the supplied amount.

public void
translate(double
double amount to add on the x axis
x
,
double
double amount to add on the y axis
y
)

Translate the point by the supplied amount.

Inherited from org.postgresql.util.PGobject:
equalsequalsgetTypeisNullsetTypesetValuetoString

Field Detail

isNullback to summary
public boolean isNull

True if the point represents null::point.

xback to summary
public double x

The X coordinate of the point.

yback to summary
public double y

The Y coordinate of the point.

Constructor Detail

PGpointback to summary
public PGpoint(double x, double y)
Parameters
x:double

coordinate

y:double

coordinate

PGpointback to summary
public PGpoint(String value) throws SQLException

This is called mainly from the other geometric types, when a point is embedded within their definition.

Parameters
value:String

Definition of this point in PostgreSQL's syntax

Annotations
@SuppressWarnings:method.invocation
Exceptions
SQLException:
if something goes wrong
PGpointback to summary
public PGpoint()

Required by the driver.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides org.postgresql.util.PGobject.clone.

Doc from org.postgresql.util.PGobject.clone.

This must be overridden to allow the object to be cloned.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

equalsback to summary
public boolean equals(@Nullable Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:@Nullable Object

Object to compare with

Returns:boolean

true if the two points are identical

Annotations
@Override
getValueback to summary
public @Nullable String getValue()

Overrides org.postgresql.util.PGobject.getValue.

Doc from org.postgresql.util.PGobject.getValue.

This must be overridden, to return the value of the object, in the form required by org.postgresql.

Returns:@Nullable String

the PGpoint in the syntax expected by org.postgresql

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.postgresql.util.PGobject.hashCode.

Doc from org.postgresql.util.PGobject.hashCode.

Compute hash. As equals() use only value. Return the same hash for the same value.

Returns:int

Value hashcode, 0 if value is null java.util.Objects#hashCode(Object)

Annotations
@Override
lengthInBytesback to summary
public int lengthInBytes()

Implements org.postgresql.util.PGBinaryObject.lengthInBytes.

Doc from org.postgresql.util.PGBinaryObject.lengthInBytes.

This method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.

Returns:int

the number of bytes needed to store this object

Annotations
@Override
moveback to summary
public void move(int x, int y)

Moves the point to the supplied coordinates.

Parameters
x:int

integer coordinate

y:int

integer coordinate

moveback to summary
public void move(double x, double y)

Moves the point to the supplied coordinates.

Parameters
x:double

double coordinate

y:double

double coordinate

setByteValueback to summary
public void setByteValue(byte[] b, int offset)

Implements org.postgresql.util.PGBinaryObject.setByteValue.

Doc from org.postgresql.util.PGBinaryObject.setByteValue.

This method is called to set the value of this object.

Parameters
b:byte[]

Definition of this point in PostgreSQL's binary syntax

offset:int

the offset in the byte array where object data starts

Annotations
@Override
setLocationback to summary
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:int

integer coordinate

y:int

integer coordinate

See Also
java.awt.Point
setLocationback to summary
public void setLocation(Point p)

Deprecated

Will be removed for avoiding a dependency to the java.desktop module.

Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this.

Parameters
p:Point

Point to move to

Annotations
@Deprecated
See Also
java.awt.Point
setValueback to summary
public void setValue(@Nullable String s) throws SQLException
Parameters
s:@Nullable String

Definition of this point in PostgreSQL's syntax

Annotations
@Override
Exceptions
SQLException:
on conversion failure
toBytesback to summary
public void toBytes(byte[] b, int offset)

Implements org.postgresql.util.PGBinaryObject.toBytes.

Populate the byte array with PGpoint in the binary syntax expected by org.postgresql.

Parameters
b:byte[]

Doc from org.postgresql.util.PGBinaryObject.toBytes.

the array to store the value, it is guaranteed to be at lest lengthInBytes in size.

offset:int

Doc from org.postgresql.util.PGBinaryObject.toBytes.

the offset in the byte array where object must be stored

Annotations
@Override
translateback to summary
public void translate(int x, int y)

Translate the point by the supplied amount.

Parameters
x:int

integer amount to add on the x axis

y:int

integer amount to add on the y axis

translateback to summary
public void translate(double x, double y)

Translate the point by the supplied amount.

Parameters
x:double

double amount to add on the x axis

y:double

double amount to add on the y axis