de.dfki.mycbr.core.casebase
Class ConceptRange

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

public final class ConceptRange
extends Range

Holds ConceptAttribute objects for a given ConceptDesc object.

Author:
myCBR Team

Constructor Summary
ConceptRange(Project p, Concept c)
          Initializes map for special attributes.
 
Method Summary
 boolean add(Instance i)
           
 void clear()
           
 Instance contains(java.lang.String name)
          Returns the ConceptAttribute associated with the given String.
 Attribute getAttribute(java.lang.Object obj)
          Gets the attribute associated with the specified Object obj.
 Concept getConcept()
           
 Instance getInstance(java.lang.String name)
          Returns the ConceptAttribute associated with the given String.
 java.util.Collection<Instance> getInstances()
          Gets the current c attributes maintained by this range.
 Attribute parseValue(java.lang.String s)
           
 void remove(java.lang.String name)
           
 void renameInstance(java.lang.String name, java.lang.String name2)
           
 void setAllInstancesMultiple(AttributeDesc d)
          Called when changing the description from having single to multiple values.
 void setAllInstancesSingle(AttributeDesc d)
          Called when changing the description from having multiple to single values.
 void update(java.util.Observable o, java.lang.Object arg)
           
 
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

ConceptRange

public ConceptRange(Project p,
                    Concept c)
Initializes map for special attributes.

Parameters:
p - the project this range belongs to
c - the concept for values maintained by this range
Method Detail

getInstance

public Instance getInstance(java.lang.String name)
                     throws java.lang.Exception
Returns the ConceptAttribute associated with the given String. Creates a new ConcpetAttribute if there is no ConceptAttribute for the given string yet.

Parameters:
name - the identifier for which the corresponding ConceptAttribute should be returned
Returns:
the ConceptAttribute specified by name
Throws:
java.lang.Exception - if name is empty

add

public boolean add(Instance i)
Parameters:
i - the instance to be added to this range
Returns:
true, if instance has been successfully added, else false.

contains

public Instance contains(java.lang.String name)
Returns the ConceptAttribute associated with the given String.

Parameters:
name - the name of the instance to be returned
Returns:
ConceptAttribute with name name or null if there is none with this name

getInstances

public java.util.Collection<Instance> getInstances()
Gets the current c attributes maintained by this range.

Returns:
the existing c attributes of the given description

getAttribute

public Attribute getAttribute(java.lang.Object obj)
Gets the attribute associated with the specified Object obj. obj is expected to be of type String. Returns result of getInstance(String) if obj is of type String, 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 String or SpecialAttribute
Returns:
SimpleAttribute that corresponds to obj, null if there is no such SimpleAttribute

getConcept

public Concept getConcept()
Returns:
the concept this range belongs to

update

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

renameInstance

public void renameInstance(java.lang.String name,
                           java.lang.String name2)
Parameters:
name - the old name of the instance
name2 - new name of the instance

parseValue

public Attribute parseValue(java.lang.String s)
                     throws java.lang.Exception
Parameters:
s - the string which should be used for parsing
Returns:
the attribute which corresponds to the given string
Throws:
java.text.ParseException - if string does not fit description
java.lang.Exception

setAllInstancesSingle

public void setAllInstancesSingle(AttributeDesc d)
Called when changing the description from having multiple to single values.


setAllInstancesMultiple

public void setAllInstancesMultiple(AttributeDesc d)
Called when changing the description from having single to multiple values.


clear

public void clear()

remove

public void remove(java.lang.String name)
Parameters:
name -