Class RasSInterval
PURPOSE:
The class represents an interval with lower and upper bound.
Operations on the interval are defined according to the
ODMG-93 standard.
The operations union, difference, and intersection are
defined according to the following table:
| ... fixed bound
-* ... open bound
class orientation union difference intersection
-----------------------------------------------------------
1 |-a-| |-b-| error a error
2 |-a-| [a1,b2] [a1,b1] [b1,a2]
2 |-b-|
3 |--a--| a error b
3 |-b-|
4 |-b-| [b1,a2] [b2,a2] [a1,b2]
4 |-a-|
5 |--b--| b error a
5 |-a-|
6 |-b-| |-a-| error a error
7 |-a-|-b-| [a1,b2] a [a2,a2]
8 |-b-|-a-| [b1,a2] a [b2,b2]
9 |--a--| a [a1,b1] b
9 |-b-|
10 |--a--| a [b2,a2] b
10 |-b-|
11 |-a-| a error a
11 |-b-|
12 |--b--| b error a
12 |-a-|
13 |--b--| b error a
13 |-a-|
-----------------------------------------------------
14 |--a--* a error b
14 |-b-|
15 |--a--* a [b2,a2] b
15 |-b-|
16 |-b-| |-a-* error a error
17 |-b-|-a-* [b1,a2] a [b2,b2]
18 |--a--* [b1,a2] [b2,a2] [a1,b2]
18 |-b-|
-----------------------------------------------------
19 *--a--| a error b
19 |-b-|
20 *--a--| a [a1,b1] b
20 |-b-|
21 *-a-| |-b-| error a error
22 *-a-|-b-| [a1,b2] a [a2,a2]
23 *--a--| [a1,b2] [a1,b1] [b1,a2]
23 |-b-|
-----------------------------------------------------
24 |--b--* b error a
24 |-a-|
25 |--b--* b error a
25 |-a-|
26 |-a-| |-b-* error a error
27 |-a-|-b-* [a1,b2] a [a2,a2]
28 |--b--* [a1,b2] [a1,b1] [b1,a2]
28 |-a-|
-----------------------------------------------------
29 *--b--| b error a
29 |-a-|
30 *--b--| b error a
30 |-a-|
31 *-b-| |-a-| error a error
32 *-b-|-a-| [b1,a2] a [b2,b2]
33 *--b--| [b1,a2] [b2,a2] [a1,b2]
33 |-a-|
-----------------------------------------------------
34 *-a-| |-b-* error a error
35 *-a-|-b-* [a1,b2] a [a2,a2]
36 *-a-| [a1,b2] [a1,b1] [b1,a2]
36 |-b-*
-----------------------------------------------------
37 *-b-| |-a-* error a error
38 *-b-|-a-* [b1,a2] a [b2,b2]
39 *-b-| [b1,a2] [a1,b1] [a1,b2]
39 |-a-*
-----------------------------------------------------
40 *-a-| b error a
40 *-b-|
41 *-a-| a error a
41 *-b-|
42 *-b-| a [b2,a2] b
42 *-a-|
-----------------------------------------------------
43 |-a-* a [a1,b1] b
43 |-b-*
44 |-a-* a error a
44 |-b-*
45 |-b-* b error a
45 |-a-*
-----------------------------------------------------
46 *-a-* |-b-| a error b
47 *-b-* |-a-| b error a
48 *-a-* a [b2,a2] b
48 *-b-|
49 *-a-* a [a1,b1] b
49 |-b-*
50 *-b-* b error a
50 *-a-|
51 *-b-* b error a
51 |-a-*
52 *-a-* a error a
52 *-b-*
Attention: The difference operation has to be reconsidered in future
concerning a discrete interpretation of the intervals.
The closure operation defines an interval which is the smallest
interval containing the two operands.
The method intersectsWith() returns 0 in the error cases of the
intersection operation and 1 otherwise.-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor creates an interval with open bounds.RasSInterval(char c1, char c2) Constructor for an SInterval with an open bounds.RasSInterval(char c, long high) Constructor for an SInterval with an open lower bound.RasSInterval(long low, char c) Constructor for an SInterval with an open upper bound.RasSInterval(long low, long high) Constructor for an SInterval with fixed bounds.RasSInterval(String stringRep) Constructor taking a string representation of the SInterval (for example "*:200").RasSInterval(RasSInterval sint) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionadd(RasSInterval interval) Deprecated.This methdod provides just another name for the createUnion method and might not be supported in future versions.addToSelf(RasSInterval interval) Deprecated.This methdod provides just another name for the unionWith method and might not be supported in future versions.closureOf(RasSInterval interval1, RasSInterval interval2) Calculates the closure of two SIntervals.closureWith(RasSInterval interval) Calculates the closure of the current SInterval and the given one.createClosure(RasSInterval interval) Returns a new SInterval calculated from the closure of the current SInterval and the given one.createDifference(RasSInterval interval) Returns a new SInterval calculated from a difference of the current SInterval and the given one.createIntersection(RasSInterval interval) Returns a new SInterval calculated from the intersection of the current SInterval and the given one.createUnion(RasSInterval interval) Returns a new SInterval calculated from a union of the current SInterval and the given one.diff(RasSInterval interval) Deprecated.This methdod provides just another name for the createDifference method and might not be supported in future versions.differenceOf(RasSInterval interval1, RasSInterval interval2) Calculates the difference of two SIntervals.differenceWith(RasSInterval interval) Calculates the difference of the current SInterval and the given one.diffFromSelf(RasSInterval interval) Deprecated.This methdod provides just another name for the differenceWith method and might not be supported in future versions.booleanequals(RasSInterval interval) Method for testing equality of two SIntervals.longhigh()Gets the upper bound of the interval.intersectionOf(RasSInterval interval1, RasSInterval interval2) This method calculates the intersection of two SIntervals.intersectionWith(RasSInterval interval) Calculates the intersection of the current SInterval and the given one.intintersectsWith(RasSInterval interval) Determines if the current interval intersects with the given one.booleanChecks if the upper bound is fix.booleanChecks if the lower bound is fix.longlow()Gets the lower bound of the interval.mult(RasSInterval interval) Deprecated.This methdod provides just another name for the createIntersection method and might not be supported in future versions.multWithSelf(RasSInterval interval) Deprecated.This methdod provides just another name for the intersectionWith method and might not be supported in future versions.booleannotEquals(RasSInterval interval) Method for testing inequality of two SIntervals.voidsetHigh(char c) Sets the upper bound open.voidsetHigh(long high) Sets the upper bound to a fixed value.voidsetInterval(char c1, char c2) Sets both bounds open.voidsetInterval(char c, long high) Sets the lower bound open and the upper bound to a fixed value.voidsetInterval(long low, char c) Sets the upper bound open and the lower bound to a fixed value.voidsetInterval(long low, long high) Sets both bounds to a fixed value.voidsetLow(char c) Sets the lower bound open.voidsetLow(long low) Sets the lower bound to a fixed value.toString()gives back the string representationunionOf(RasSInterval interval1, RasSInterval interval2) Calculates the union of two SIntervals.unionWith(RasSInterval interval) Calculates the union of the current SIntervall with another one.
-
Constructor Details
-
RasSInterval
public RasSInterval()The default constructor creates an interval with open bounds. -
RasSInterval
Copy constructor.- Parameters:
sint- SInterval to be copied
-
RasSInterval
Constructor taking a string representation of the SInterval (for example "*:200").- Parameters:
stringRep- the string representation of the SInterval- Throws:
RasResultIsNoIntervalException
-
RasSInterval
Constructor for an SInterval with fixed bounds.- Parameters:
low- the lower boundhigh- the upper bound- Throws:
RasResultIsNoIntervalException
-
RasSInterval
public RasSInterval(char c, long high) Constructor for an SInterval with an open lower bound.- Parameters:
c- arbitrary character, usually '*'. The value of this parameter is meaningless, it's only needed in order to provide a constructor similar to the one for fixed bounds.high- the upper bound
-
RasSInterval
public RasSInterval(long low, char c) Constructor for an SInterval with an open upper bound.- Parameters:
low- the lower boundc- arbitrary character, usually '*'. The value of this parameter is meaningless, it's only needed in order to provide a constructor similar to the one for fixed bounds.
-
RasSInterval
public RasSInterval(char c1, char c2) Constructor for an SInterval with an open bounds. For both parameters, arbitrary characters (usually '*') can be specified. The values of these parameters are meaningless, they are only needed in order to provide a constructor similar to the one for fixed bounds.- Parameters:
c1- arbitrary characterc2- arbitrary character
-
-
Method Details
-
equals
Method for testing equality of two SIntervals. Two SIntervals are equal if they have the same lower and upper bounds.- Parameters:
interval- the SInterval that is compared to this SInterval- Returns:
- true if the two SIntervals are equal
-
notEquals
Method for testing inequality of two SIntervals. Two SIntervals are inequal if they have different lower or upper bounds.- Parameters:
interval- the SInterval that is compared to this SInterval- Returns:
- true if the two SIntervals are not equal
-
low
public long low()Gets the lower bound of the interval.- Returns:
- the lower bound
-
high
public long high()Gets the upper bound of the interval.- Returns:
- the upper bound
-
isLowFixed
public boolean isLowFixed()Checks if the lower bound is fix.- Returns:
- true if the lower bound is fix, false otherwise
-
isHighFixed
public boolean isHighFixed()Checks if the upper bound is fix.- Returns:
- true if the lower bound is fix, false otherwise
-
setLow
Sets the lower bound to a fixed value.- Parameters:
low- the new lower bound- Throws:
RasResultIsNoIntervalException
-
setHigh
Sets the upper bound to a fixed value.- Parameters:
high- the new upper bound- Throws:
RasResultIsNoIntervalException
-
setLow
public void setLow(char c) Sets the lower bound open.- Parameters:
c- arbitrary character (usually '*')
-
setHigh
public void setHigh(char c) Sets the upper bound open.- Parameters:
c- arbitrary character (usually '*')
-
setInterval
Sets both bounds to a fixed value.- Parameters:
low- the new lower boundhigh- the new upper bound- Throws:
RasResultIsNoIntervalException
-
setInterval
public void setInterval(char c, long high) Sets the lower bound open and the upper bound to a fixed value.- Parameters:
c- arbitrary character (usually '*')high- the new upper bound
-
setInterval
public void setInterval(long low, char c) Sets the upper bound open and the lower bound to a fixed value.- Parameters:
low- the new lower boundc- arbitrary character (usually '*')
-
setInterval
public void setInterval(char c1, char c2) Sets both bounds open.- Parameters:
c1- arbitrary character (usually '*')c2- arbitrary character (usually '*')
-
intersectsWith
Determines if the current interval intersects with the given one.- Parameters:
interval- the interval to be compared- Returns:
-1 if the intervals do not intersect <classNo> if the intervals do intersect, where <classNo> is one of the classes specified in the description for class RasSInterval.
-
unionOf
public RasSInterval unionOf(RasSInterval interval1, RasSInterval interval2) throws RasResultIsNoIntervalException Calculates the union of two SIntervals.Note that this operation modifies the current object. If you want to get a new SInterval, use
createUnioninstead.- Parameters:
interval1- the first SIntervalinterval2- the second SInterval- Returns:
- the current SInterval (representing the union of interval1 and interval2)
- Throws:
RasResultIsNoIntervalException
-
unionWith
Calculates the union of the current SIntervall with another one.Note that this operation modifies the current object. If you want to get a new SInterval, use
createUnioninstead.- Parameters:
interval- the SInterval to be used for the union- Returns:
- the current SInterval (after the union with interval)
- Throws:
RasResultIsNoIntervalException
-
addToSelf
Deprecated.This methdod provides just another name for the unionWith method and might not be supported in future versions. Please useunionWithinstead.- Parameters:
interval- the SInterval to be unioned with this SInterval- Returns:
- the union of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
createUnion
Returns a new SInterval calculated from a union of the current SInterval and the given one.- Parameters:
mint- the SInterval to be unioned with this SInterval- Returns:
- the union of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
add
Deprecated.This methdod provides just another name for the createUnion method and might not be supported in future versions. Please usecreateUnioninstead.- Parameters:
interval- the SInterval to be unioned with this SInterval- Returns:
- the union of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
differenceOf
public RasSInterval differenceOf(RasSInterval interval1, RasSInterval interval2) throws RasResultIsNoIntervalException Calculates the difference of two SIntervals.Note that this operation modifies the current object. If you want to get a new SInterval, use
createDifferenceinstead.- Parameters:
interval1- the first SIntervalinterval2- the second SInterval- Returns:
- the current SInterval (representing the difference of interval1 and interval2)
- Throws:
RasResultIsNoIntervalException
-
differenceWith
Calculates the difference of the current SInterval and the given one.Note that this operation modifies the current object. If you want to get a new SInterval, use
createDifferenceinstead.- Parameters:
interval- the SInterval used for building the difference- Returns:
- the current SInterval (representing the difference of this SInterval and interval)
- Throws:
RasResultIsNoIntervalException
-
diffFromSelf
Deprecated.This methdod provides just another name for the differenceWith method and might not be supported in future versions. Please usedifferenceWithinstead.- Parameters:
interval- the SInterval used for building the difference- Returns:
- the current SInterval (representing the difference of this SInterval and interval)
- Throws:
RasResultIsNoIntervalException
-
createDifference
Returns a new SInterval calculated from a difference of the current SInterval and the given one.- Parameters:
interval- the SInterval used for calculating the difference with the current SInterval- Returns:
- the difference of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
diff
Deprecated.This methdod provides just another name for the createDifference method and might not be supported in future versions. Please usecreateDifferenceinstead.- Parameters:
interval- the SInterval used for calculating the difference with the current SInterval- Returns:
- the difference of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
intersectionOf
public RasSInterval intersectionOf(RasSInterval interval1, RasSInterval interval2) throws RasResultIsNoIntervalException This method calculates the intersection of two SIntervals.Note that this operation modifies the current object. If you want to get a new SInterval, use
createIntersectioninstead.- Parameters:
interval1- the first SIntervalinterval2- the second SInterval- Returns:
- the current SInterval (representing the intersection of interval1 and interval2)
- Throws:
RasResultIsNoIntervalException
-
intersectionWith
Calculates the intersection of the current SInterval and the given one.Note that this operation modifies the current object. If you want to get a new SInterval, use
createIntersectioninstead.- Parameters:
interval- the SInterval used for building the intersection- Returns:
- the current SInterval (representing the intersection of this SInterval and interval)
- Throws:
RasResultIsNoIntervalException
-
multWithSelf
Deprecated.This methdod provides just another name for the intersectionWith method and might not be supported in future versions. Please useintersectionWithinstead.- Parameters:
interval- the SInterval used for building the intersection- Returns:
- the intersection of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
createIntersection
Returns a new SInterval calculated from the intersection of the current SInterval and the given one.- Parameters:
interval- the SInterval used for calculating the intersection with the current SInterval- Returns:
- the intersection of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
mult
Deprecated.This methdod provides just another name for the createIntersection method and might not be supported in future versions. Please usecreateIntersectioninstead.- Parameters:
interval- the SInterval used for calculating the intersection with the current SInterval- Returns:
- the intersection of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
closureOf
public RasSInterval closureOf(RasSInterval interval1, RasSInterval interval2) throws RasResultIsNoIntervalException Calculates the closure of two SIntervals.Note that this operation modifies the current object. If you want to get a new SInterval, use
createClosureinstead.- Parameters:
interval1- the first SIntervalinterval2- the second SInterval- Returns:
- the current SInterval (representing the closure of interval1 and interval2)
- Throws:
RasResultIsNoIntervalException
-
closureWith
Calculates the closure of the current SInterval and the given one.Note that this operation modifies the current object. If you want to get a new SInterval, use
createClosureinstead.- Parameters:
interval- the SInterval used for building the closure- Returns:
- the current SInterval (representing the closure of this SInterval and interval)
- Throws:
RasResultIsNoIntervalException
-
createClosure
Returns a new SInterval calculated from the closure of the current SInterval and the given one.- Parameters:
interval- the SInterval used for calculating the closure with the current SInterval- Returns:
- the closure of this SInterval and interval
- Throws:
RasResultIsNoIntervalException
-
toString
gives back the string representation
-