data
Class Interval

java.lang.Object
  extended by data.Interval
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
IntervalNoUnion

public class Interval
extends java.lang.Object
implements java.io.Serializable

Interval

This class represents a real interval, comprised of two real bounds. Each of the bound can be open or closed. The values of the bounds are doubles. To represent singletons, we use the use the representation [5,5], i.e. the two bounds must be equals and included.

Copyright(c) 2005 Université Laval, LSFM research group.

Version:
1.0
Author:
Nicolas Richard
See Also:
Serialized Form

Field Summary
static Interval EMPTY_INTERVAL
          Constant representing an empty interval.
static Interval R
          Represents the valid set of numbers.
 
Constructor Summary
Interval(boolean isLowerBoundIncluded, double lowerBound, double upperBound, boolean isUpperBoundIncluded)
          Constructor with parameters.
Interval(Interval i)
          Copy constructor.
Interval(java.lang.String s)
          Build a new interval from a string.
 
Method Summary
 Interval closure()
          Returns a closure of the current interval.
 boolean equals(java.lang.Object o)
          Determines if the object is an interval equals to this one.
 double getLowerBound()
          Returns the real number representing the lower bound.
 double getNb()
          Returns the value of nb : 0 : no transition point to this interval 1 : at least one transition has this interval as domain 2 : at least one transition has this interval as image 3 : at least one transition has this interval both as domain and image
 double getUpperBound()
          Returns the real number representing the upper bound.
 int hashCode()
          Returning an integer representing this interval
static Interval intersectionOf(Interval i, Interval j)
          Compute the intersection of two intervals.
 boolean intersectsWith(Interval i)
          Determines if the current interval intersects with i.
 boolean isDiscrete()
          An interval is discrete should both of its bound be equals and included.
 boolean isIn(double v)
          Determines if the value v is indeed included in the interval.
 boolean isIncluded(Interval smaller)
          Determines if the smaller interval is included into this one.
 boolean isLowerBoundIncluded()
          Returns true should the lower bound be included
 boolean isUpperBoundIncluded()
          Returns true should the upper bound be included
 void setIsLowerBoundIncluded(boolean isLowerBoundIncluded)
          Change the inclusion status of the lower bound.
 void setIsUpperBoundIncluded(boolean isUpperBoundIncluded)
          Change the inclusion status of the upper bound.
 void setLowerBound(double lowerBound)
          Change the value of the lower bound.
 void setNb(int n)
          Change the value of nb : 0 : no transition point to this interval 1 : at least one transition has this interval as domain 2 : at least one transition has this interval as image 3 : at least one transition has this interval both as domain and image
 void setUpperBound(double upperBound)
          Change the value of the upper bound.
 java.lang.String toString()
          Converting the current interval to string
static Interval unionOf(Interval i, Interval j)
          Compute the union of two intervals, should these intersect.
 boolean verifierInvariants()
          Verifies the interval's integrity
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_INTERVAL

public static final Interval EMPTY_INTERVAL
Constant representing an empty interval.


R

public static final Interval R
Represents the valid set of numbers. Note, we do not accept infinity as a number.

Constructor Detail

Interval

public Interval(boolean isLowerBoundIncluded,
                double lowerBound,
                double upperBound,
                boolean isUpperBoundIncluded)
Constructor with parameters.

Parameters:
isLowerBoundIncluded - true should the lower bound be included
lowerBound - value of the lower bound
upperBound - value of the upper bound
isUpperBoundIncluded - true should the upper bound be included

Interval

public Interval(Interval i)
Copy constructor.

Parameters:
i - the interval to copy.

Interval

public Interval(java.lang.String s)
         throws DataParserException
Build a new interval from a string. Possible formats are :

Parameters:
s - the string representing the interval.
Throws:
DataParserException - should the string represent no valid interval.
Method Detail

isLowerBoundIncluded

public boolean isLowerBoundIncluded()
Returns true should the lower bound be included

Returns:
true if the lower bound is included

isUpperBoundIncluded

public boolean isUpperBoundIncluded()
Returns true should the upper bound be included

Returns:
true if the upper bound is included

getLowerBound

public double getLowerBound()
Returns the real number representing the lower bound.

Returns:
the real number representing the lower bound.

getUpperBound

public double getUpperBound()
Returns the real number representing the upper bound.

Returns:
the real number representing the upper bound.

getNb

public double getNb()
Returns the value of nb : 0 : no transition point to this interval 1 : at least one transition has this interval as domain 2 : at least one transition has this interval as image 3 : at least one transition has this interval both as domain and image

Returns:
one of these 4 values

setUpperBound

public void setUpperBound(double upperBound)
Change the value of the upper bound.

Parameters:
upperBound - the new value of the upper bound.

setLowerBound

public void setLowerBound(double lowerBound)
Change the value of the lower bound.

Parameters:
lowerBound - the new value of the lower bound.

setIsUpperBoundIncluded

public void setIsUpperBoundIncluded(boolean isUpperBoundIncluded)
Change the inclusion status of the upper bound.

Parameters:
isUpperBoundIncluded - true should the upper bound be included now.

setIsLowerBoundIncluded

public void setIsLowerBoundIncluded(boolean isLowerBoundIncluded)
Change the inclusion status of the lower bound.

Parameters:
isLowerBoundIncluded - true should the lower bound be included now.

setNb

public void setNb(int n)
Change the value of nb : 0 : no transition point to this interval 1 : at least one transition has this interval as domain 2 : at least one transition has this interval as image 3 : at least one transition has this interval both as domain and image

Parameters:
n - one of these 4 numbers

isIn

public boolean isIn(double v)
Determines if the value v is indeed included in the interval. Should v be exactly equal to one of the bound, it must be included.

Parameters:
v - the value to check
Returns:
true should v be part of the interval

equals

public boolean equals(java.lang.Object o)
Determines if the object is an interval equals to this one. We can compare an interval to a string. Assuming the string represents a valid interval and that this one is equivalent to this one, true will be returned.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to verify
Returns:
true should the object be an interval equivalent to this one
See Also:
Interval(String)

isIncluded

public boolean isIncluded(Interval smaller)
Determines if the smaller interval is included into this one.

Parameters:
smaller - the smaller interval to determine the inclusion value.
Returns:
true if the smaller interval is included into this one.

isDiscrete

public boolean isDiscrete()
An interval is discrete should both of its bound be equals and included.

Returns:
true should both bounds be equals and included.

intersectsWith

public boolean intersectsWith(Interval i)
Determines if the current interval intersects with i.

Parameters:
i - An interval that might intersect.
Returns:
true if the current interval intersects with i.

intersectionOf

public static Interval intersectionOf(Interval i,
                                      Interval j)
Compute the intersection of two intervals. Should the two interval not intersect, an empty interval will be returned.

Parameters:
i - the first interval
j - the second interval
Returns:
the intersection of i and j.

closure

public Interval closure()
Returns a closure of the current interval. The closure of an interval posess the same bounds. However, they are both closed.

Returns:
The closure of the current interval.

unionOf

public static Interval unionOf(Interval i,
                               Interval j)
Compute the union of two intervals, should these intersect. If they don't intersect, they may have one bound in common, else an empty interval will be returned.

Parameters:
i - the first intervals.
j - Interval
Returns:
Interval

toString

public java.lang.String toString()
Converting the current interval to string

Overrides:
toString in class java.lang.Object
Returns:
a string representing this interval

verifierInvariants

public boolean verifierInvariants()
Verifies the interval's integrity

Returns:
'True' if the interval respects the constraints

hashCode

public int hashCode()
Returning an integer representing this interval

Overrides:
hashCode in class java.lang.Object
Returns:
an integer representing this interval