org.apache.ace.range
Class Range

java.lang.Object
  extended by org.apache.ace.range.Range

public class Range
extends Object

Class that captures a simple, modifiable range.


Constructor Summary
Range(long number)
          Create a range that consists of a single number.
Range(long low, long high)
          Creates a range from a lower to a higher bound.
Range(String representation)
          Create a new range based on a string representation of that range.
 
Method Summary
 boolean contains(long number)
          Checks if a number falls within this range.
 long getHigh()
          Returns the higher bound.
 long getLow()
          Returns the lower bound.
 void setHigh(long high)
          Sets a new higher bound.
 void setLow(long low)
          Sets a new lower bound.
 String toRepresentation()
          Converts the range to a string representation that can be parsed back to a new Range object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Range

public Range(String representation)
Create a new range based on a string representation of that range.

Parameters:
representation - the string representation

Range

public Range(long number)
Create a range that consists of a single number.

Parameters:
number - the number

Range

public Range(long low,
             long high)
Creates a range from a lower to a higher bound.

Parameters:
low - the lower bound
high - the higher bound
Method Detail

getLow

public long getLow()
Returns the lower bound.

Returns:
the lower bound

setLow

public void setLow(long low)
Sets a new lower bound. Will make sure the range stays valid, so if the higher bound is smaller than the new lower bound, it will be made equal to this new lower bound.

Parameters:
low - the new lower bound

getHigh

public long getHigh()
Returns the higher bound.

Returns:
the higher bound

setHigh

public void setHigh(long high)
Sets a new higher bound. Will make sure the range stays valid, so if the lower bound is bigger than the new higher bound, it will be made equal to this new higher bound.

Parameters:
high - the new higher bound

contains

public boolean contains(long number)
Checks if a number falls within this range.

Parameters:
number - the number to check
Returns:
true if the number was inside the range

toRepresentation

public String toRepresentation()
Converts the range to a string representation that can be parsed back to a new Range object.

Returns:


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.