de.dfki.mycbr.core.casebase
Class Instance

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.casebase.Attribute
          extended by de.dfki.mycbr.core.casebase.Instance
All Implemented Interfaces:
IExplainable, java.util.Observer

public final class Instance
extends Attribute
implements java.util.Observer, IExplainable

Represents values occurring in query and or cases. Each attribute knows its description and therefore knows how similar it is to other attributes of the same description. Attributes for a fixed description are maintained by ranges (classes implementing interface Range).

Author:
myCBR Team

Field Summary
static java.lang.String QUERY_ID
           
 
Constructor Summary
Instance(Concept concept, java.lang.String id)
          Creates new value for the specified description.
 
Method Summary
 boolean addAttribute(AttributeDesc desc, Attribute a)
           
 boolean addAttribute(AttributeDesc desc, java.lang.Object value)
           
 boolean addAttribute(java.lang.String n, Attribute a)
          Sets the value of the attribute specified by desc to att.
 boolean addAttribute(java.lang.String n, java.lang.Object value)
           
 void clean(AttributeDesc desc)
           
 Attribute getAttForDesc(AttributeDesc attDesc)
          Returns the attribute for the given description.
 java.util.HashMap<AttributeDesc,Attribute> getAttributes()
          Gets all the attribute values for this c.
 Concept getConcept()
          Gets the description for this attribute to determine similarity functions or restrictions for the value of this attribute.
 Explainable getExpType()
           
 java.lang.String getName()
           
 java.lang.String getValueAsString()
          Returns the string representation of this c attribute.
 boolean isAdapted()
           
 void removeAttribute(AttributeDesc desc)
          Removes the given attribute.
 void reset()
          Sets the value for every direct or inherited attribute description to the default special value undefined.
 void setAdapted(boolean adapted)
           
 void setAttsUnknown()
          Sets the value for every direct or inherited attribute description to the default special value undefined.
 void setName(java.lang.String n)
           
 java.lang.String toString()
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_ID

public static final java.lang.String QUERY_ID
See Also:
Constant Field Values
Constructor Detail

Instance

public Instance(Concept concept,
                java.lang.String id)
Creates new value for the specified description. Be aware that this instance will not belong to the concept, if you call this constructor. Better call Concept.addInstance(String) to create an instance properly!

Parameters:
concept - description of this attribute
id - the name of this instance
Method Detail

setName

public void setName(java.lang.String n)
Parameters:
n - new name of this

getName

public java.lang.String getName()
Specified by:
getName in interface IExplainable
Returns:
the name of this

getConcept

public Concept getConcept()
Gets the description for this attribute to determine similarity functions or restrictions for the value of this attribute.

Returns:
the description of this attribute

getAttributes

public java.util.HashMap<AttributeDesc,Attribute> getAttributes()
Gets all the attribute values for this c.

Returns:
the list of attributes of this c

removeAttribute

public void removeAttribute(AttributeDesc desc)
Removes the given attribute.

Parameters:
desc - the attribute to be removed

addAttribute

public boolean addAttribute(java.lang.String n,
                            Attribute a)
Sets the value of the attribute specified by desc to att. First checks whether this c attribute has a direct attribute description that corresponds to the description of the given attribute. If not, checks whether this c attribute has a super class that has a direct attribute description that corresponds to the given att's description. In any of these cases the given att is added to this c's attributes. Otherwise does nothing. It is assumed that you set the values for c attributes that are contained within this c attribute via composition separately by first adding the values to the corresponding c attribute and then add this c attribute as an attribute here.

Parameters:
n - the name of the attribute description
a - the value to be added to this c attribute.
Returns:
true, if the attribute was successfully added, false otherwise.

addAttribute

public boolean addAttribute(java.lang.String n,
                            java.lang.Object value)
                     throws java.text.ParseException
Parameters:
n - the name of the attribute description
value - the value of the attribute to be added
Returns:
true, if the attribute has been successfully added
Throws:
java.text.ParseException - if the value does not fit the description

addAttribute

public boolean addAttribute(AttributeDesc desc,
                            java.lang.Object value)
                     throws java.text.ParseException
Parameters:
desc - the description of the attribute to be added
value - the value to be added
Returns:
true, if attribute has been added successfully, false otherwise
Throws:
java.text.ParseException - if the value does not fit the description

addAttribute

public boolean addAttribute(AttributeDesc desc,
                            Attribute a)
Parameters:
desc - the description of the attribute to be added
a - the attribute to be added
Returns:
true, if the attribute has been successfully added, false otherwise

getAttForDesc

public Attribute getAttForDesc(AttributeDesc attDesc)
Returns the attribute for the given description. Returns null, if there is no attribute for this description.

Parameters:
attDesc - the description for which the attribute should be returned
Returns:
the attribute corresponding to attDesc, null if there is none

getValueAsString

public java.lang.String getValueAsString()
Returns the string representation of this c attribute.

Specified by:
getValueAsString in class Attribute
Returns:
string representation of this c attribute

getExpType

public Explainable getExpType()
Specified by:
getExpType in interface IExplainable
Returns:
type of explainable object.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

clean

public void clean(AttributeDesc desc)
Parameters:
desc - the instance will be cleaned wrt this description

reset

public void reset()
Sets the value for every direct or inherited attribute description to the default special value undefined.


setAttsUnknown

public void setAttsUnknown()
Sets the value for every direct or inherited attribute description to the default special value undefined.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setAdapted

public void setAdapted(boolean adapted)
Parameters:
adapted - the adapted to set

isAdapted

public boolean isAdapted()
Returns:
the adapted