HiRISE

HiRISE.HiPlan.Utilities
Class Interval

java.lang.Object
  extended by HiRISE.HiPlan.Utilities.Interval
All Implemented Interfaces:
Comparable<Interval>

public class Interval
extends Object
implements Comparable<Interval>

An immutable closed interval.

See Also:
IntervalUnion

Field Summary
static String ID
          Class identification name with source code version and date.
 
Constructor Summary
Interval(double min, double max)
          Creates a new interval with the indicated minimum and maximum values.
 
Method Summary
static void checkValues(String label, double[] values, Interval allowed)
          Checks whether the input values are appropriate for a particular interval.
 int compareTo(Interval i)
          Compares this interval with another interval for order.
 boolean contains(double value)
          Determines whether an indicated value is within the closed interval.
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 String format(int decimalPlaces)
           
 double getMax()
          Gets the interval's maximum value.
 double getMin()
          Gets the interval's minimum value.
 int hashCode()
          Returns a hash code value for this interval.
 double[] toArray()
           
 String toString()
          Gets a string representation for this interval.
static Interval valueOf(String text, Interval allowed)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

Interval

public Interval(double min,
                double max)
Creates a new interval with the indicated minimum and maximum values.

The minimum value, min, must be less than the maximum value, max. If not, an exception is thrown.

Throws:
IllegalArgumentException - if min is equal to or greater than max.
Method Detail

getMin

public double getMin()
Gets the interval's minimum value.

Returns:
the minimum value.

getMax

public double getMax()
Gets the interval's maximum value.

Returns:
the maximum value.

contains

public boolean contains(double value)
Determines whether an indicated value is within the closed interval.

Because the interval is a closed interval, the minimum and maximum values are included in the test. In other words, this test evaluates the following:

minvaluemax

Parameters:
value - the value to be tested.
Returns:
true if value is within the closed interval; false otherwise.

format

public String format(int decimalPlaces)

toArray

public double[] toArray()

toString

public String toString()
Gets a string representation for this interval. The string is the mathematical representation of a closed interval: [min,max].

Overrides:
toString in class Object
Returns:
a string representation of this interval.

hashCode

public int hashCode()
Returns a hash code value for this interval.

Overrides:
hashCode in class Object
Returns:
a hash code value for this interval.

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one. An interval is equal to another if and only if the minimum values are the same and the maximum values are the same.

Overrides:
equals in class Object
Parameters:
o - the object to which this object is compared.
Returns:
true if the objects are equal; false otherwise.

compareTo

public int compareTo(Interval i)
Compares this interval with another interval for order. This method returns a negative integer, zero, or a positive integer as this interval is less than, equal to, or greater than the other interval.

This interval is less than the input interval if its getMin() value is less. It is greater than the input interval if its minimum is greater than. If the two intervals have the same minimum, their maximum values are similarly compared.

Specified by:
compareTo in interface Comparable<Interval>
Parameters:
i - the interval to be compared.
Returns:
a negative integer, zero, or a positive integer as this interval is less than, equal to, or greater than the specified interval.

valueOf

public static Interval valueOf(String text,
                               Interval allowed)

checkValues

public static void checkValues(String label,
                               double[] values,
                               Interval allowed)
Checks whether the input values are appropriate for a particular interval. The value parameter must be non-null. It must have a non-zero, even number of values. Each of the values must fall within the input allowed interval. A given matched pair of values must not form an inverted or single-point interval.

If any of these rules is violated, an exception is thrown.

Parameters:
label - a label used in forming exception messages.
values - the values to check.
allowed - the allowed values.
Throws:
NullPointerException - if values is null.
IllegalArgumentException - if values are bad.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona