de.dfki.mycbr.core.casebase
Class IntegerRange

java.lang.Object
  extended by de.dfki.mycbr.core.casebase.Range
      extended by de.dfki.mycbr.core.casebase.IntegerRange
All Implemented Interfaces:
java.util.Observer

public final class IntegerRange
extends Range

Holds IntegerAttributes for a given IntegerDescription. Each time an integer is used in a case the IntegerRange returns a reference to the corresponding IntegerAttribute object or creates a new one. SpecialAttributes are also handled for each SpecialAttribute used in the current project

Author:
myCBR Team

Constructor Summary
IntegerRange(Project prj, IntegerDesc d)
          Initializes internal data structures according to maximal Integer of integer attributes (given by IntegerDesc.getMax() - IntegerDesc.getMin()).
 
Method Summary
 boolean containsInteger(java.lang.Integer value)
          Returns true, if there is a IntegerAttribute object contained in this range, false otherwise.
 Attribute getAttribute(java.lang.Object obj)
          Gets the attribute associated with the specified Object obj.
 IntegerDesc getDesc()
          Gets the integer description of the attributes maintained by this range.
 java.util.HashMap<java.lang.Integer,IntegerAttribute> getIntegers()
          Gets the map which associates an IntegerAttribute object with each integer used as value.
 IntegerAttribute getIntegerValue(int value)
          Returns the IntegerAttribute associated with the given value.
 SimpleAttribute getValue(int v)
          Returns the attribute for the given Integer.
 Attribute parseValue(java.lang.String string)
           
 void update(java.util.Observable ob, java.lang.Object o)
           
 
Methods inherited from class de.dfki.mycbr.core.casebase.Range
getProject, setProject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerRange

public IntegerRange(Project prj,
                    IntegerDesc d)
Initializes internal data structures according to maximal Integer of integer attributes (given by IntegerDesc.getMax() - IntegerDesc.getMin()).

Parameters:
prj - the project this range belongs to
d - the integer description for attributes maintained by this range
Method Detail

getDesc

public IntegerDesc getDesc()
Gets the integer description of the attributes maintained by this range.

Returns:
the integer description for values included in this range

containsInteger

public boolean containsInteger(java.lang.Integer value)
Returns true, if there is a IntegerAttribute object contained in this range, false otherwise.

Parameters:
value - the integer value to be checked
Returns:
true, if value is contained in this range, false otherwise.

getIntegerValue

public IntegerAttribute getIntegerValue(int value)
Returns the IntegerAttribute associated with the given value. Creates a new IntegerAttribute if there is no IntegerAttribute for the given value yet. Returns null if the specified value is not contained in the interval given by IntegerDesc.getMin() and IntegerDesc.getMin() of the given integer description.

Parameters:
value - the value for which the corresponding IntegerAttribute should be returned
Returns:
the IntegerAttribute specified by value, null if value is not an allowed value

getIntegers

public java.util.HashMap<java.lang.Integer,IntegerAttribute> getIntegers()
Gets the map which associates an IntegerAttribute object with each integer used as value.

Returns:
map associating IntegerAttribuet objects with integers

getAttribute

public Attribute getAttribute(java.lang.Object obj)
Gets the attribute associated with the specified Object obj. obj is expected to be of type Integer or String . Returns result of getIntegerValue(int) if obj is of type Integer, result of Project.getSpecialAttribute(String) if obj is of type SpecialAttribute, else returns null. Is needed for MultipleRange.

Specified by:
getAttribute in class Range
Parameters:
obj - representing Integer or SpecialAttribute
Returns:
SimpleAttribute that corresponds to obj, null if there is no such SimpleAttribute

getValue

public SimpleAttribute getValue(int v)
Returns the attribute for the given Integer.

Parameters:
v - an attribute with this value should be returned
Returns:
integer attribute associated with the given value

update

public void update(java.util.Observable ob,
                   java.lang.Object o)

parseValue

public Attribute parseValue(java.lang.String string)
Parameters:
string - the string which should be used for parsing
Returns:
the attribute which corresponds to the given string