org.postgresql.geometric
Class PGbox

java.lang.Object
  extended by org.postgresql.util.PGobject
      extended by org.postgresql.geometric.PGbox
All Implemented Interfaces:
Serializable, Cloneable, PGBinaryObject

public class PGbox
extends PGobject
implements PGBinaryObject, Serializable, Cloneable

This represents the box datatype within org.postgresql.

See Also:
Serialized Form

Field Summary
 PGpoint[] point
          These are the two points.
 
Fields inherited from class org.postgresql.util.PGobject
type, value
 
Constructor Summary
PGbox()
          Required constructor
PGbox(double x1, double y1, double x2, double y2)
           
PGbox(PGpoint p1, PGpoint p2)
           
PGbox(String s)
           
 
Method Summary
 Object clone()
          This must be overidden to allow the object to be cloned
 boolean equals(Object obj)
          This must be overidden to allow comparisons of objects
 String getValue()
          This must be overidden, to return the value of the object, in the form required by org.postgresql.
 int hashCode()
          Compute hash.
 int lengthInBytes()
          This method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.
 void setByteValue(byte[] b, int offset)
          This method is called to set the value of this object.
 void setValue(String value)
          This method sets the value of this object.
 void toBytes(byte[] bytes, int offset)
          This method is called the to store the value of the object, in the binary form required by org.postgresql.
 
Methods inherited from class org.postgresql.util.PGobject
getType, setType, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

point

public PGpoint[] point
These are the two points.

Constructor Detail

PGbox

public PGbox(double x1,
             double y1,
             double x2,
             double y2)
Parameters:
x1 - first x coordinate
y1 - first y coordinate
x2 - second x coordinate
y2 - second y coordinate

PGbox

public PGbox(PGpoint p1,
             PGpoint p2)
Parameters:
p1 - first point
p2 - second point

PGbox

public PGbox(String s)
      throws SQLException
Parameters:
s - Box definition in PostgreSQL syntax
Throws:
SQLException - if definition is invalid

PGbox

public PGbox()
Required constructor

Method Detail

setValue

public void setValue(String value)
              throws SQLException
This method sets the value of this object. It should be overidden, but still called by subclasses.

Overrides:
setValue in class PGobject
Parameters:
value - a string representation of the value of the object
Throws:
SQLException - thrown if value is invalid for this type

setByteValue

public void setByteValue(byte[] b,
                         int offset)
Description copied from interface: PGBinaryObject
This method is called to set the value of this object.

Specified by:
setByteValue in interface PGBinaryObject
Parameters:
b - Definition of this point in PostgreSQL's binary syntax
offset - the offset in the byte array where object data starts

equals

public boolean equals(Object obj)
Description copied from class: PGobject
This must be overidden to allow comparisons of objects

Overrides:
equals in class PGobject
Parameters:
obj - Object to compare with
Returns:
true if the two boxes are identical

hashCode

public int hashCode()
Description copied from class: PGobject
Compute hash. As equals() use only value. Return the same hash for the same value.

Overrides:
hashCode in class PGobject
Returns:
Value hashcode, 0 if value is null Objects

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: PGobject
This must be overidden to allow the object to be cloned

Overrides:
clone in class PGobject
Throws:
CloneNotSupportedException

getValue

public String getValue()
Description copied from class: PGobject
This must be overidden, to return the value of the object, in the form required by org.postgresql.

Overrides:
getValue in class PGobject
Returns:
the PGbox in the syntax expected by org.postgresql

lengthInBytes

public int lengthInBytes()
Description copied from interface: PGBinaryObject
This method is called to return the number of bytes needed to store this object in the binary form required by org.postgresql.

Specified by:
lengthInBytes in interface PGBinaryObject
Returns:
the number of bytes needed to store this object

toBytes

public void toBytes(byte[] bytes,
                    int offset)
Description copied from interface: PGBinaryObject
This method is called the to store the value of the object, in the binary form required by org.postgresql.

Specified by:
toBytes in interface PGBinaryObject
Parameters:
bytes - the array to store the value, it is guaranteed to be at lest PGBinaryObject.lengthInBytes() in size.
offset - the offset in the byte array where object must be stored


Copyright © 2016 PostgreSQL Global Development Group. All rights reserved.