Bali Share 1.1.18

oracle.bali.share.collection
Class Range

java.lang.Object
  |
  +--oracle.bali.share.collection.Range
All Implemented Interfaces:
java.lang.Cloneable

public class Range
extends java.lang.Object
implements java.lang.Cloneable

A class that encapsulates a lower and upper limit


Constructor Summary
Range(int lowerLimit, int upperLimit)
          Constructs a Range object with the specified upper and lower limits.
 
Method Summary
static Range[] addRanges(Range[] a, Range[] b)
          Utility method for adding ranges.
 java.lang.Object clone()
          Support for cloning.
 int getLowerLimit()
          Returns the lower limit of the range
 int getUpperLimit()
          Returns the upper limit of the range
 boolean inRange(int value)
          Checks whether the value is inside the range
static boolean rangesContain(Range[] ranges, int value)
           
static boolean rangesContain(Range[] a, Range[] b)
          Returns true if the set of ranges a completely encompases the set of ranges b.
static Range[] subtractRanges(Range[] a, Range[] b)
          Utility method for subtracting ranges, such that the result is a duplicate of 'a', with the removal of any areas intersected by 'b'.
 java.lang.String toString()
          Returns the String representation of the Range values.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Range

public Range(int lowerLimit,
             int upperLimit)
Constructs a Range object with the specified upper and lower limits.
Parameters:
lower - lower limit of the Range.
upper - upper limit of the Range.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Support for cloning.
Overrides:
clone in class java.lang.Object

getLowerLimit

public int getLowerLimit()
Returns the lower limit of the range

getUpperLimit

public int getUpperLimit()
Returns the upper limit of the range

inRange

public boolean inRange(int value)
Checks whether the value is inside the range
Parameters:
value - the value to check

toString

public java.lang.String toString()
Returns the String representation of the Range values.
Overrides:
toString in class java.lang.Object

addRanges

public static Range[] addRanges(Range[] a,
                                Range[] b)
Utility method for adding ranges. Currently does not ensure uniqueness.
Returns:
an array of Range objects sorted by lower bound.

subtractRanges

public static Range[] subtractRanges(Range[] a,
                                     Range[] b)
Utility method for subtracting ranges, such that the result is a duplicate of 'a', with the removal of any areas intersected by 'b'.
Returns:
an array of Range objects sorted by lower bound.

rangesContain

public static boolean rangesContain(Range[] ranges,
                                    int value)

rangesContain

public static boolean rangesContain(Range[] a,
                                    Range[] b)
Returns true if the set of ranges a completely encompases the set of ranges b. Used by several of the public methods.

Bali Share 1.1.18