de.dfki.mycbr.core.model
Class SymbolDesc

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.model.AttributeDesc
          extended by de.dfki.mycbr.core.model.SimpleAttDesc
              extended by de.dfki.mycbr.core.model.SymbolDesc
All Implemented Interfaces:
IExplainable, TaxonomyNode, java.util.Observer
Direct Known Subclasses:
BooleanDesc, SpecialDesc

public class SymbolDesc
extends SimpleAttDesc
implements TaxonomyNode

Description for symbol attributes. Gives restrictions to the allowed values for this attribute.

Author:
myCBR Team

Constructor Summary
SymbolDesc(Concept owner, java.lang.String name, java.util.Set<java.lang.String> allowedValues)
          Initializes this with the given name and the allowed values.
 
Method Summary
 OrderedSymbolFct addOrderedSymbolFct(java.lang.String name, boolean active)
          Creates a new OrderedSymbolFct for the given description.
 SymbolAttribute addSymbol(java.lang.String value)
          Adds value to the list of allowed symbols of this description.
 SymbolFct addSymbolFct(java.lang.String name, boolean active)
          Creates a new SymbolFct for the given description.
 TaxonomyFct addTaxonomyFct(java.lang.String name, boolean active)
          Creates a new TaxonomyFct for the given description.
 boolean canOverride(AttributeDesc desc)
          Checks whether this attribute description can override the given attribute description
 boolean fits(Attribute att)
          Checks whether the given attribute fits this.
 boolean fitsSingle(Attribute att)
          Checks whether a single attribute fits the constraints for this.
 java.util.Set<java.lang.String> getAllowedValues()
          Gets the allowed values.
 Attribute getAttribute(java.lang.String value)
          Returns SymbolAttribute object representing the specified value.
 java.lang.Integer getIndexOf(SimpleAttribute att)
           
 java.util.List<TaxonomyNode> getNodes()
          Returns a list of nodes allowed for the taxonomy this is contained in.
 java.util.Collection<SymbolAttribute> getSymbolAttributes()
          Returns Collection of symbol attributes representing the allowed symbols for the given description.
 boolean isAllowedValue(java.lang.String value)
          Tells you whether the specified string is an allowed value for this or not.
 void removeSymbol(java.lang.String value)
          Removes the given string from the list of allowed symbols.
 boolean renameValue(java.lang.String oldValue, java.lang.String newValue)
          Changes the symbol attribute's value associated with oldValue to newValue.
 
Methods inherited from class de.dfki.mycbr.core.model.SimpleAttDesc
addFct, deleteAllFcts, deleteSimFct, getFct, getSimFcts, renameFct
 
Methods inherited from class de.dfki.mycbr.core.model.AttributeDesc
delete, getAttribute, getExpType, getName, getOwner, isMultiple, setMultiple, setName, setOwner, toString, update
 
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
 

Constructor Detail

SymbolDesc

public SymbolDesc(Concept owner,
                  java.lang.String name,
                  java.util.Set<java.lang.String> allowedValues)
           throws java.lang.Exception
Initializes this with the given name and the allowed values. The name should be unique within the attributes of the c description containing this description. Creates a new range for this description.

Parameters:
owner - the owner of this description
name - the name to be used for this description.
allowedValues - the values which can be used for attributes of this description
Throws:
java.lang.Exception - if owner already has a description with that name
Method Detail

addOrderedSymbolFct

public final OrderedSymbolFct addOrderedSymbolFct(java.lang.String name,
                                                  boolean active)
Creates a new OrderedSymbolFct for the given description.

Parameters:
name - the name of the new function.
active - the new function will be used in all amalgamation functions known for the owner
Returns:
the Similarity.getFunction for description desc

getAttribute

public Attribute getAttribute(java.lang.String value)
Returns SymbolAttribute object representing the specified value.

Parameters:
value - the string representing the value that should be returned
Returns:
value representing the specified string, null if there is none.

addSymbol

public SymbolAttribute addSymbol(java.lang.String value)
Adds value to the list of allowed symbols of this description. Returns SymbolAttribute object representing the specified value.

Parameters:
value - the string representing the value that should be returned
Returns:
value representing the specified string.

getSymbolAttributes

public final java.util.Collection<SymbolAttribute> getSymbolAttributes()
Returns Collection of symbol attributes representing the allowed symbols for the given description.

Returns:
collection of allowed attributes

getAllowedValues

public final java.util.Set<java.lang.String> getAllowedValues()
Gets the allowed values. Allowed values are those strings that can be used for values of this description

Returns:
the allowed values for attributes of this description

isAllowedValue

public boolean isAllowedValue(java.lang.String value)
Tells you whether the specified string is an allowed value for this or not.

Parameters:
value - the string which should be checked for allowance
Returns:
true, if value is an allowed value, false otherwise

removeSymbol

public void removeSymbol(java.lang.String value)
Removes the given string from the list of allowed symbols.

Parameters:
value - the value of the symbol attribute to be removed

canOverride

public boolean canOverride(AttributeDesc desc)
Description copied from class: AttributeDesc
Checks whether this attribute description can override the given attribute description

Specified by:
canOverride in class SimpleAttDesc
Parameters:
desc - the description which should be overridden by this
Returns:
true, if this can override the given function, false otherwise.

getIndexOf

public java.lang.Integer getIndexOf(SimpleAttribute att)
Parameters:
att - the attribute whose index should be returned
Returns:
the index of the given attribute, null if it does not belong to this

fits

public boolean fits(Attribute att)
Description copied from class: AttributeDesc
Checks whether the given attribute fits this. Be aware that if this is multiple then single values will not fit. For checking whether single values fit this description without taking multiple values into account call AttributeDesc.fitsSingle(Attribute)

Overrides:
fits in class AttributeDesc
Parameters:
att - the attribute which should be checked for fitting this
Returns:
true, if att is a valid attribute for this description, false otherwise

fitsSingle

public boolean fitsSingle(Attribute att)
Description copied from class: AttributeDesc
Checks whether a single attribute fits the constraints for this. Returns true, if att is a valid SpecialAttribute or if att can be used as a single value of a multiple attribute. If this is not multiple calls AttributeDesc.fits(Attribute)

Overrides:
fitsSingle in class AttributeDesc
Parameters:
att - the attribute which should be checked
Returns:
true, when att can be used as value of this or in multiple attribute

renameValue

public boolean renameValue(java.lang.String oldValue,
                           java.lang.String newValue)
Changes the symbol attribute's value associated with oldValue to newValue.

Parameters:
oldValue - the old value
newValue - the new value

addSymbolFct

public final SymbolFct addSymbolFct(java.lang.String name,
                                    boolean active)
Creates a new SymbolFct for the given description.

Parameters:
name - the name of the new function
active - if true, the new function will be used in all amalgamation functions known for the owner of this.
Returns:
the new symbol function

addTaxonomyFct

public final TaxonomyFct addTaxonomyFct(java.lang.String name,
                                        boolean active)
Creates a new TaxonomyFct for the given description.

Parameters:
name - the name of the new function
active - if true, the new function will be used in all amalgamation functions known for the owner of this.
Returns:
the new taxonomy function

getNodes

public java.util.List<TaxonomyNode> getNodes()
Description copied from interface: TaxonomyNode
Returns a list of nodes allowed for the taxonomy this is contained in. Does not include root, although root is TaxonomyNode, too.

Specified by:
getNodes in interface TaxonomyNode
Returns:
list of nodes for the corresponding taxonomy