arom.kernel
Class AromInterval

java.lang.Object
  |
  +--arom.util.Interval
        |
        +--arom.kernel.AromInterval

public class AromInterval
extends Interval
implements Cloneable

The AromInterval class represents positive interval of integer which are inherited. This class is used to define role's cardinality as well as multi valued variables. An AromInterval is defined by positive integer bounds and by the AromInterval which is it's ancestor. Undefined bounds means bounds that are inherited from the ancestor interval.

Version:
0.1

Field Summary
protected  AromInterval ancestor
           
protected  AromAccessor owner
           
static Integer UNDEF
          instance that indicates 'undefined' bounds.
 
Fields inherited from class arom.util.Interval
lower, upper
 
Constructor Summary
AromInterval(AromAccessor owner)
          Construct a new interval owned by the specified accessor.
AromInterval(AromAccessor owner, AromInterval parent)
          Construct a new interval which inherit from the specified ancestor interval.
 
Method Summary
 Object clone()
          Creates a clone of this interval.
 Integer getMaxCard()
          Returns the maximum bound of this interval.
 Integer getMinCard()
          Returns the minimum bounds of this interval.
 void setAncestor(AromInterval parent)
          Sets a new ancestor interval for this interval.
 void setCard(Integer min, Integer max)
          Sets the minimum and the maximum bounds of this interval.
 void setMaxCard(Integer max)
          Sets the maximum bound of the interval.
 void setMinCard(Integer min)
          Sets the minimum bound of the interval.
 String toString()
          Returns a string representation of this interval.
 
Methods inherited from class arom.util.Interval
contains, containsValue, equals, getLowerBound, getUpperBound, quotify, setBounds, setLowerBound, setUpperBound
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEF

public static Integer UNDEF
instance that indicates 'undefined' bounds.

owner

protected AromAccessor owner

ancestor

protected AromInterval ancestor
Constructor Detail

AromInterval

public AromInterval(AromAccessor owner)
Construct a new interval owned by the specified accessor.
Parameters:
owner - the accessor that use this interval.

AromInterval

public AromInterval(AromAccessor owner,
                    AromInterval parent)
Construct a new interval which inherit from the specified ancestor interval.
Parameters:
owner - the accessor that use this interval.
parent - the interval parent of this interval.
Method Detail

setAncestor

public void setAncestor(AromInterval parent)
                 throws AromIllegalSetMultiplicityException
Sets a new ancestor interval for this interval.
Parameters:
parent - the interval ancestor of this one.
Throws:
AromIllegalSetMultiplicityException - if the ancestors bounds are incompatible with the bounds defined for this interval.

setMinCard

public void setMinCard(Integer min)
                throws AromIllegalSetMultiplicityException
Sets the minimum bound of the interval.
Parameters:
min - the new minimum bound.
Throws:
AromIllegalSetCardException - if the value min is incompatible with the ancestor interval or with the maximum bound.

setMaxCard

public void setMaxCard(Integer max)
                throws AromIllegalSetMultiplicityException
Sets the maximum bound of the interval.
Parameters:
max - the new maximum bound.
Throws:
AromIllegalSetCardException - if the value max is incompatible with the ancestor interval or with the minimum bound.

setCard

public void setCard(Integer min,
                    Integer max)
             throws AromIllegalSetMultiplicityException
Sets the minimum and the maximum bounds of this interval.
Parameters:
min - the new minimum bound.
max - the new maximum bound.
Throws:
AromIllegalSetCardException - if min and max did'nt define an interval on positive integer* or if this values are incompatible with the ancestor interval.

getMinCard

public Integer getMinCard()
Returns the minimum bounds of this interval.
Returns:
the minimum bounds of this interval.

getMaxCard

public Integer getMaxCard()
Returns the maximum bound of this interval.
Returns:
the maximum bound of this interval.

clone

public Object clone()
Creates a clone of this interval.
Returns:
a copy of this interval.
Overrides:
clone in class Object

toString

public String toString()
Returns a string representation of this interval.
Returns:
a string representation of this interval.
Overrides:
toString in class Interval