com.amazon.redshift.geometric

## Class RedshiftBox

- java.lang.Object
- - com.amazon.redshift.util.RedshiftObject
  - - com.amazon.redshift.geometric.RedshiftBox

All Implemented Interfaces:
  RedshiftBinaryObject, Serializable, Cloneable

    public class RedshiftBox
    extends RedshiftObject
    implements RedshiftBinaryObject, Serializable, Cloneable

This represents the box datatype within com.amazon.redshift.

See Also:
  Serialized Form

### Field Summary

Fields
`RedshiftPoint[]` `point` These are the two points.

### Fields inherited from class com.amazon.redshift.util.RedshiftObject

`type, value`

### Constructor Summary

Constructors
Constructor and Description
`RedshiftBox()` Required constructor.
`RedshiftBox(double x1, double y1, double x2, double y2)`
`RedshiftBox(RedshiftPoint p1, RedshiftPoint p2)`
`RedshiftBox(String s)`

### Method Summary

Methods
`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 com.amazon.redshift.
`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 com.amazon.redshift.
`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 com.amazon.redshift.

### Methods inherited from class com.amazon.redshift.util.RedshiftObject

`getType, setType, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### point

    public RedshiftPoint[] point

These are the two points.

### Constructor Detail

#### RedshiftBox

    public RedshiftBox(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

#### RedshiftBox

    public RedshiftBox(RedshiftPoint p1,
               RedshiftPoint p2)

Parameters:
  `p1` - first point
  `p2` - second point

#### RedshiftBox

    public RedshiftBox(String s)
                throws SQLException

Parameters:
  `s` - Box definition in Redshift syntax
Throws:
  `SQLException` - if definition is invalid

#### RedshiftBox

    public RedshiftBox()

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 `RedshiftObject`
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: `RedshiftBinaryObject`
This method is called to set the value of this object.

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

#### equals

    public boolean equals(Object obj)

Description copied from class: `RedshiftObject`
This must be overidden to allow comparisons of objects.

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

#### hashCode

    public int hashCode()

Description copied from class: `RedshiftObject`
Compute hash. As equals() use only value. Return the same hash for the same value.

Overrides:
  `hashCode` in class `RedshiftObject`
Returns:
  Value hashcode, 0 if value is null `Objects.hashCode(Object)`

#### clone

    public Object clone()
                 throws CloneNotSupportedException

Description copied from class: `RedshiftObject`
This must be overidden to allow the object to be cloned.

Overrides:
  `clone` in class `RedshiftObject`
Throws:
  `CloneNotSupportedException`

#### getValue

    public String getValue()

Description copied from class: `RedshiftObject`
This must be overidden, to return the value of the object, in the form required by com.amazon.redshift.

Overrides:
  `getValue` in class `RedshiftObject`
Returns:
  the RedshiftBox in the syntax expected by com.amazon.redshift

#### lengthInBytes

    public int lengthInBytes()

Description copied from interface: `RedshiftBinaryObject`
This method is called to return the number of bytes needed to store this object in the binary form required by com.amazon.redshift.

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

#### toBytes

    public void toBytes(byte[] bytes,
               int offset)

Description copied from interface: `RedshiftBinaryObject`
This method is called the to store the value of the object, in the binary form required by com.amazon.redshift.

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