uk.co.agena.minerva.util.model
Class Range

java.lang.Object
  extended by uk.co.agena.minerva.util.model.Range

public class Range
extends java.lang.Object

This class encapsulates a lower bound and upper bound that together define a numerical range.


Constructor Summary
Range()
          Creates a new Range.
Range(double lowerBound, double upperBound)
          Creates a new Range with the specified lower and upper bounds.
 
Method Summary
 boolean contains(double value)
          Determines whether the supplied value lies in this range or not.
 boolean contains(double value, boolean excludeLowerBound, boolean excludeUpperBound)
          Determines whether the supplied value lies in this range or not.
 boolean contains(Range r)
          This method returns true if this range contains the argument range r.
 double getLowerBound()
          Returns the lower bound.
 double getUpperBound()
          Returns the upper bound.
 double midPoint()
          Returns the midpoint of the upper and lower bounds
 void setLowerBound(double lowerBound)
          Sets the lower bound.
 void setUpperBound(double upperBound)
          Sets the upper bound.
 double size()
          Calculates the size of the range.
 java.lang.String toIntString()
          Rounds the range to integers and then represents as a string.
 java.lang.String toString()
          Returns a String representation of the Range in the following format: [LOWERBOUND] - [UPPERBOUND]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Range

public Range()
Creates a new Range. Only used by Castor.


Range

public Range(double lowerBound,
             double upperBound)
      throws MinervaRangeException
Creates a new Range with the specified lower and upper bounds.

Parameters:
lowerBound - the lower bound of the Range
upperBound - the upper bound of the Range
Throws:
MinervaRangeException - if upperBound < lowerBound
Method Detail

getLowerBound

public double getLowerBound()
Returns the lower bound.

Returns:
the lower bound

setLowerBound

public void setLowerBound(double lowerBound)
Sets the lower bound.

Parameters:
lowerBound - the lower bound

getUpperBound

public double getUpperBound()
Returns the upper bound.

Returns:
the upper bound

setUpperBound

public void setUpperBound(double upperBound)
Sets the upper bound.

Parameters:
upperBound - the upper bound

midPoint

public double midPoint()
Returns the midpoint of the upper and lower bounds

Returns:
the midpoint of the upper and lower bounds

contains

public boolean contains(double value)
Determines whether the supplied value lies in this range or not.

Parameters:
value - the value of interest
Returns:
true if it is in the range, false otherwise

contains

public boolean contains(double value,
                        boolean excludeLowerBound,
                        boolean excludeUpperBound)
Determines whether the supplied value lies in this range or not. But can optionally exclude the bounds. By default the contains method includes the upper and lower bounds (i.e. false).

Parameters:
value - the value of interest
Returns:
true if it is in the range, false otherwise

size

public double size()
Calculates the size of the range.

Returns:
the size of the range

toString

public java.lang.String toString()
Returns a String representation of the Range in the following format: [LOWERBOUND] - [UPPERBOUND]

Overrides:
toString in class java.lang.Object
Returns:
the String representation of the Range

toIntString

public java.lang.String toIntString()
Rounds the range to integers and then represents as a string.

Returns:
a hyphen-separated Integer Range

contains

public boolean contains(Range r)
This method returns true if this range contains the argument range r. i.e. r.lowerbound >= this.lowerbound and r.upperbound =< this.upperbound.

Parameters:
r -
Returns:


Copyright © 2006 Agena Ltd. All Rights Reserved.