de.dfki.mycbr.core.casebase
Class SymbolRange

java.lang.Object
  extended by de.dfki.mycbr.core.casebase.Range
      extended by de.dfki.mycbr.core.casebase.SymbolRange
All Implemented Interfaces:
java.util.Observer
Direct Known Subclasses:
SpecialRange

public class SymbolRange
extends Range

Holds SymbolAttributes for a given SymbolDesc. The SymbolAttributes are initialized during construction. SpecialAttributes have to be handled separately, so that you can have SpecialAttribute instead of SymbolAttributes.

Author:
myCBR Team

Constructor Summary
SymbolRange(Project prj, SymbolDesc description, java.util.Collection<java.lang.String> allowedValues)
          Creates one SymbolAttribute object for each String specified by allowedValues.
 
Method Summary
 SymbolAttribute addSymbolValue(java.lang.String value)
           
 Attribute getAttribute(java.lang.Object obj)
          Gets the attribute associated with the specified Object obj.
 int getHighestIndex()
           
 java.util.HashMap<SymbolAttribute,java.lang.Integer> getIndexes()
           
 java.lang.Integer getIndexOf(SimpleAttribute att)
          Returns the index of the given attribute.
 java.util.HashMap<java.lang.String,SymbolAttribute> getSymbols()
          Get a map which associates a SymbolAttribute with each allowed value for the given attribute description.
 SymbolAttribute getSymbolValue(java.lang.String symbol)
          Returns the SymbolAttribute associated with the given String.
 void initIndexes()
          Initializes the private files indexes.
 SymbolAttribute removeAttribute(java.lang.String symbol)
          Removes the SymbolAttribute associated with the given string from this range.
 void renameSymbol(java.lang.String value, java.lang.String value2)
           
 void setHighestIndex(int i)
           
 void setIndexes(java.util.HashMap<SymbolAttribute,java.lang.Integer> i)
           
 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

SymbolRange

public SymbolRange(Project prj,
                   SymbolDesc description,
                   java.util.Collection<java.lang.String> allowedValues)
Creates one SymbolAttribute object for each String specified by allowedValues.

Parameters:
prj - the project this range belongs to
description - the symbol description for this attribute
allowedValues - the allowed values for this attribute
Method Detail

initIndexes

public void initIndexes()
Initializes the private files indexes. This field specifies a linear order for indexing symbol attributes. By default, the first attribute specified in the given symbol description is the smallest element in the linear order. Has to be called after initSymbolAttributes(Collection)


getSymbolValue

public final SymbolAttribute getSymbolValue(java.lang.String symbol)
Returns the SymbolAttribute associated with the given String. Returns null if the symbol does not specify an allowed value for this attribute. Creates a new SymbolAttribute if there is no SymbolAttribute for the given symbol yet. Updates index structure if a new SymbolAttribute object is added.

Parameters:
symbol - the value for which the corresponding SymbolAttribute should be returned
Returns:
the SymbolAttribute specified by symbol, null if symbol is not an allowed value
See Also:
SymbolDesc.isAllowedValue(String)

getSymbols

public final java.util.HashMap<java.lang.String,SymbolAttribute> getSymbols()
Get a map which associates a SymbolAttribute with each allowed value for the given attribute description.

Returns:
map which associates SymbolAttribute with string

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 getSymbolValue(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

getIndexOf

public final java.lang.Integer getIndexOf(SimpleAttribute att)
Returns the index of the given attribute. Returns null, If the attribute is not maintained by this range.

Parameters:
att - the attribute whose index should be returned
Returns:
index of the given att, null if this attribute is unknown

removeAttribute

public final SymbolAttribute removeAttribute(java.lang.String symbol)
Removes the SymbolAttribute associated with the given string from this range. Returns the corresponding SymbolAttribute or null if there is no attribute that corresponds to symbol. Updates index structures.

Parameters:
symbol - the symbol to be removed from this range
Returns:
the attribute corresponding to this symbol, null if there is none

update

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

renameSymbol

public final void renameSymbol(java.lang.String value,
                               java.lang.String value2)
Parameters:
value - the old name of the symbol
value2 - the new name of the symbol

addSymbolValue

public SymbolAttribute addSymbolValue(java.lang.String value)
Parameters:
value - the value of the new symbol attribute
Returns:
the new symbol attribute with value value

setIndexes

public final void setIndexes(java.util.HashMap<SymbolAttribute,java.lang.Integer> i)
Parameters:
i - the indexes to set

getIndexes

public final java.util.HashMap<SymbolAttribute,java.lang.Integer> getIndexes()
Returns:
the indexes

setHighestIndex

public final void setHighestIndex(int i)
Parameters:
i - the highestIndex to set

getHighestIndex

public final int getHighestIndex()
Returns:
the highestIndex