Package rasj

Class RasSInterval

java.lang.Object
rasj.RasSInterval

public class RasSInterval extends Object

 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 Details

    • RasSInterval

      public RasSInterval()
      The default constructor creates an interval with open bounds.
    • RasSInterval

      public RasSInterval(RasSInterval sint)
      Copy constructor.
      Parameters:
      sint - SInterval to be copied
    • RasSInterval

      public RasSInterval(String stringRep) throws RasResultIsNoIntervalException
      Constructor taking a string representation of the SInterval (for example "*:200").
      Parameters:
      stringRep - the string representation of the SInterval
      Throws:
      RasResultIsNoIntervalException
    • RasSInterval

      public RasSInterval(long low, long high) throws RasResultIsNoIntervalException
      Constructor for an SInterval with fixed bounds.
      Parameters:
      low - the lower bound
      high - 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 bound
      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.
    • 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 character
      c2 - arbitrary character
  • Method Details

    • equals

      public boolean equals(RasSInterval interval)
      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

      public boolean notEquals(RasSInterval interval)
      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

      public void setLow(long low) throws RasResultIsNoIntervalException
      Sets the lower bound to a fixed value.
      Parameters:
      low - the new lower bound
      Throws:
      RasResultIsNoIntervalException
    • setHigh

      public void setHigh(long high) throws RasResultIsNoIntervalException
      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

      public void setInterval(long low, long high) throws RasResultIsNoIntervalException
      Sets both bounds to a fixed value.
      Parameters:
      low - the new lower bound
      high - 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 bound
      c - 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

      public int intersectsWith(RasSInterval interval)
      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 createUnion instead.

      Parameters:
      interval1 - the first SInterval
      interval2 - the second SInterval
      Returns:
      the current SInterval (representing the union of interval1 and interval2)
      Throws:
      RasResultIsNoIntervalException
    • unionWith

      public RasSInterval unionWith(RasSInterval interval) throws RasResultIsNoIntervalException
      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 createUnion instead.

      Parameters:
      interval - the SInterval to be used for the union
      Returns:
      the current SInterval (after the union with interval)
      Throws:
      RasResultIsNoIntervalException
    • addToSelf

      public RasSInterval addToSelf(RasSInterval interval) throws RasResultIsNoIntervalException
      Deprecated.
      This methdod provides just another name for the unionWith method and might not be supported in future versions. Please use unionWith instead.
      Parameters:
      interval - the SInterval to be unioned with this SInterval
      Returns:
      the union of this SInterval and interval
      Throws:
      RasResultIsNoIntervalException
    • createUnion

      public RasSInterval createUnion(RasSInterval interval) throws RasResultIsNoIntervalException
      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 use createUnion instead.
      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 createDifference instead.

      Parameters:
      interval1 - the first SInterval
      interval2 - the second SInterval
      Returns:
      the current SInterval (representing the difference of interval1 and interval2)
      Throws:
      RasResultIsNoIntervalException
    • differenceWith

      public RasSInterval differenceWith(RasSInterval interval) throws RasResultIsNoIntervalException
      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 createDifference instead.

      Parameters:
      interval - the SInterval used for building the difference
      Returns:
      the current SInterval (representing the difference of this SInterval and interval)
      Throws:
      RasResultIsNoIntervalException
    • diffFromSelf

      public RasSInterval diffFromSelf(RasSInterval interval) throws RasResultIsNoIntervalException
      Deprecated.
      This methdod provides just another name for the differenceWith method and might not be supported in future versions. Please use differenceWith instead.
      Parameters:
      interval - the SInterval used for building the difference
      Returns:
      the current SInterval (representing the difference of this SInterval and interval)
      Throws:
      RasResultIsNoIntervalException
    • createDifference

      public RasSInterval createDifference(RasSInterval interval) throws RasResultIsNoIntervalException
      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 use createDifference instead.
      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 createIntersection instead.

      Parameters:
      interval1 - the first SInterval
      interval2 - the second SInterval
      Returns:
      the current SInterval (representing the intersection of interval1 and interval2)
      Throws:
      RasResultIsNoIntervalException
    • intersectionWith

      public RasSInterval intersectionWith(RasSInterval interval) throws RasResultIsNoIntervalException
      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 createIntersection instead.

      Parameters:
      interval - the SInterval used for building the intersection
      Returns:
      the current SInterval (representing the intersection of this SInterval and interval)
      Throws:
      RasResultIsNoIntervalException
    • multWithSelf

      public RasSInterval multWithSelf(RasSInterval interval) throws RasResultIsNoIntervalException
      Deprecated.
      This methdod provides just another name for the intersectionWith method and might not be supported in future versions. Please use intersectionWith instead.
      Parameters:
      interval - the SInterval used for building the intersection
      Returns:
      the intersection of this SInterval and interval
      Throws:
      RasResultIsNoIntervalException
    • createIntersection

      public RasSInterval createIntersection(RasSInterval interval) throws RasResultIsNoIntervalException
      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 use createIntersection instead.
      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 createClosure instead.

      Parameters:
      interval1 - the first SInterval
      interval2 - the second SInterval
      Returns:
      the current SInterval (representing the closure of interval1 and interval2)
      Throws:
      RasResultIsNoIntervalException
    • closureWith

      public RasSInterval closureWith(RasSInterval interval) throws RasResultIsNoIntervalException
      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 createClosure instead.

      Parameters:
      interval - the SInterval used for building the closure
      Returns:
      the current SInterval (representing the closure of this SInterval and interval)
      Throws:
      RasResultIsNoIntervalException
    • createClosure

      public RasSInterval createClosure(RasSInterval interval) throws RasResultIsNoIntervalException
      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

      public String toString()
      gives back the string representation
      Overrides:
      toString in class Object