org.eigenbase.sarg
Class SargEndpoint

java.lang.Object
  extended by org.eigenbase.sarg.SargEndpoint
All Implemented Interfaces:
Comparable<SargEndpoint>
Direct Known Subclasses:
SargMutableEndpoint

public class SargEndpoint
extends Object
implements Comparable<SargEndpoint>

SargEndpoint represents an endpoint of a (SargInterval).

Instances of SargEndpoint are immutable from outside this package. Subclass SargMutableEndpoint is provided for manipulation from outside the package.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sarg/SargEndpoint.java#15 $
Author:
John V. Sichi

Field Summary
protected  SargBoundType boundType
           
protected  RexNode coordinate
          Coordinate for this endpoint, constrained to be either RexLiteral, RexInputRef, RexDynamicParam, or null to represent infinity (positive or negative infinity is implied by boundType).
protected  RelDataType dataType
          Datatype for endpoint value.
protected  SargFactory factory
          Factory which produced this endpoint.
protected  SargStrictness strictness
           
 
Constructor Summary
SargEndpoint(SargFactory factory, RelDataType dataType)
           
 
Method Summary
(package private) static int compareCoordinates(RexNode coord1, RexNode coord2)
           
 int compareTo(SargEndpoint other)
           
private  int convertBytes(ByteBuffer value)
           
private  int convertNumber(BigDecimal value)
           
private  int convertString(NlsString value)
           
private  void convertToTargetType()
           
(package private)  void copyFrom(SargEndpoint other)
           
 boolean equals(Object other)
           
 SargBoundType getBoundType()
           
 RexNode getCoordinate()
           
 RelDataType getDataType()
           
 int getInfinitude()
           
 SargStrictness getStrictness()
           
 SargStrictness getStrictnessComplement()
           
 int getStrictnessSign()
           
 int hashCode()
           
 boolean isClosed()
           
 boolean isFinite()
           
 boolean isNull()
           
 boolean isOpen()
           
 boolean isTouching(SargEndpoint other)
          Tests whether this endpoint "touches" another one (not necessarily overlapping).
(package private)  void setFinite(SargBoundType boundType, SargStrictness strictness, RexNode coordinate)
          Sets a finite value for this endpoint.
(package private)  void setInfinity(int infinitude)
          Sets this endpoint to either negative or positive infinity.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

protected final SargFactory factory
Factory which produced this endpoint.


dataType

protected final RelDataType dataType
Datatype for endpoint value.


coordinate

protected RexNode coordinate
Coordinate for this endpoint, constrained to be either RexLiteral, RexInputRef, RexDynamicParam, or null to represent infinity (positive or negative infinity is implied by boundType).


boundType

protected SargBoundType boundType
See Also:
getBoundType()

strictness

protected SargStrictness strictness
See Also:
getStrictness()
Constructor Detail

SargEndpoint

SargEndpoint(SargFactory factory,
             RelDataType dataType)
See Also:
SargFactory.newEndpoint(org.eigenbase.reltype.RelDataType)
Method Detail

copyFrom

void copyFrom(SargEndpoint other)

setInfinity

void setInfinity(int infinitude)
Sets this endpoint to either negative or positive infinity. An infinite endpoint implies an open bound (negative infinity implies a lower bound, while positive infinity implies an upper bound).

Parameters:
infinitude - either -1 or +1

setFinite

void setFinite(SargBoundType boundType,
               SargStrictness strictness,
               RexNode coordinate)
Sets a finite value for this endpoint.

Parameters:
boundType - bound type (upper/lower)
strictness - boundary strictness
coordinate - endpoint position

convertToTargetType

private void convertToTargetType()

convertString

private int convertString(NlsString value)

convertBytes

private int convertBytes(ByteBuffer value)

convertNumber

private int convertNumber(BigDecimal value)

isClosed

public boolean isClosed()
Returns:
true if this endpoint represents a closed (exact) bound; false if open (strict)

isOpen

public boolean isOpen()
Returns:
opposite of isClosed

isFinite

public boolean isFinite()
Returns:
false if this endpoint represents infinity (either positive or negative); true if a finite coordinate

getInfinitude

public int getInfinitude()
Returns:
-1 for negative infinity, +1 for positive infinity, 0 for a finite endpoint

getCoordinate

public RexNode getCoordinate()
Returns:
coordinate of this endpoint

isNull

public boolean isNull()
Returns:
true if this endpoint has the null value for its coordinate

getDataType

public RelDataType getDataType()
Returns:
target datatype for coordinate

getBoundType

public SargBoundType getBoundType()
Returns:
boundary type this endpoint represents

isTouching

public boolean isTouching(SargEndpoint other)
Tests whether this endpoint "touches" another one (not necessarily overlapping). For example, the upper bound of the interval (1, 10) touches the lower bound of the interval [10, 20), but not of the interval (10, 20).

Parameters:
other - the other endpoint to test
Returns:
true if touching; false if discontinuous

compareCoordinates

static int compareCoordinates(RexNode coord1,
                              RexNode coord2)

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(SargEndpoint other)
Specified by:
compareTo in interface Comparable<SargEndpoint>

getStrictness

public SargStrictness getStrictness()
Returns:
SargStrictness of this bound

getStrictnessComplement

public SargStrictness getStrictnessComplement()
Returns:
complement of SargStrictness of this bound

getStrictnessSign

public int getStrictnessSign()
Returns:
-1 for infinitesimally below (open upper bound, strictly less than), 0 for exact equality (closed bound), 1 for infinitesimally above (open lower bound, strictly greater than)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object