Class SimilarityModelImpl
java.lang.Object
de.uni_trier.wi2.procake.similarity.impl.SimilarityModelImpl
- All Implemented Interfaces:
SimilarityModel
- Author:
- Rainer Maximini
-
Field Summary
Fields inherited from interface de.uni_trier.wi2.procake.similarity.SimilarityModel
COMPONENT, LOG_CREATING_NEW_MEASURE_FAILED, LOG_NO_MODEL_READER_FOUND, LOG_READING_INITIAL_MODEL_FAILED, LOG_SIMILARITY_NAME_ALREADY_EXISTS, LOG_SIMILARITY_NAME_NOT_FOUND
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addParameter
(String name, String value) Adds the given name and value to the similarity parameter list.void
addSimilarityMeasure
(SimilarityMeasure measure, String name) Newly createdSimilarityMeasure
s are not registered automatically.createAndRegisterSimilarityMeasure
(String uniqueName, String measureTemplateName, DataClass dataClass) Creates a newSimilarityMeasure
and registerscreateSimilarityMeasure
(String name, DataClass dataClass) Creates a newSimilarityMeasure
that is not automatically registered.Returns a complete list of all parameters in the system.getParameter
(String name) The value with the given parameter name will be returned.String[]
getPossibleSimilarityMeasureFor
(DataClass dataClass) Computes all similarity measure that are possible for the given data class without any order.String[]
getPossibleSimilarityMeasureFor
(DataClass dataClass, String orderName) Computes all similarity measure that are possible for the given data class / order combination.getSimilarityMeasure
(DataClass dataClass) Returns a suitable similarity measure for the given data class.getSimilarityMeasure
(DataClass dataClass, String name) getSimilarityMeasures
(DataClass dataClass) Retrieves all registeredSimilarityMeasure
s for the givenDataClass
.String[]
getSimilarityNamesFor
(DataClass dataClass) boolean
isDefaultSimilarityMeasure
(SimilarityMeasure similarityMeasure) void
overwriteMatchingDataClasses
(Model oldModel) Checks for each measure if it contains aDataClass
reference that is present in the given 'other' Model.void
Add the similarity measure passed to thesimilarityMeasureTemplateCache
.void
removeParameter
(String name) The parameter with the given name will be removed from the internal parameter-listremoveSimilarityMeasure
(DataClass dataClass, String name) Removes the similarity measure with the given name for the given data class.Removes the given similarity measure.renameSimilarityMeasure
(DataClass dataClass, String oldName, String newName) Renames an already registeredSimilarityMeasure
.void
setDefaultSimilarityMeasure
(DataClass dataClass, String measureName) TheRetriever
uses in general the defaultSimilarityMeasure
that can be defined with this method.
-
Constructor Details
-
SimilarityModelImpl
public SimilarityModelImpl()
-
-
Method Details
-
createAndRegisterSimilarityMeasure
public SimilarityMeasure createAndRegisterSimilarityMeasure(String uniqueName, String measureTemplateName, DataClass dataClass) throws NameAlreadyExistsException Description copied from interface:SimilarityModel
Creates a newSimilarityMeasure
and registers- Specified by:
createAndRegisterSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
uniqueName
- a new unique name to identify the new measuremeasureTemplateName
- Each similarity measure contains a static field "NAME" that contains the name of the similarity measure, e.g.,SMAggregateAverage.NAME
. If this field does not exists, the similarity measure can not be instantiated.dataClass
- TheDataClass
for that the similarity measure should be created.- Returns:
- The new
SimilarityMeasure
or null if the name does not relate to a similarity * measure or the similarity measure does not fit to the data class - Throws:
NameAlreadyExistsException
- is thrown if the given name is already defined for the data class.
-
overwriteMatchingDataClasses
Description copied from interface:SimilarityModel
Checks for each measure if it contains aDataClass
reference that is present in the given 'other' Model. If so, it replaces that reference.- Specified by:
overwriteMatchingDataClasses
in interfaceSimilarityModel
- Parameters:
oldModel
- The Model whose dataclasses should be referenced
-
addSimilarityMeasure
public void addSimilarityMeasure(SimilarityMeasure measure, String name) throws NameAlreadyExistsException Description copied from interface:SimilarityModel
Newly createdSimilarityMeasure
s are not registered automatically. This must be done in this method whereby eachSimilarityMeasure
an unique name for this dataClass is defined. The correspondingDataClass
is already defined in the similarity measure.- Specified by:
addSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
measure
- the new similarity measurename
- a new unique name- Throws:
NameAlreadyExistsException
- is thrown if the given name is already defined for the data class.
-
createSimilarityMeasure
Description copied from interface:SimilarityModel
Creates a newSimilarityMeasure
that is not automatically registered. The registration must be done with theSimilarityModel.addSimilarityMeasure(SimilarityMeasure, String)
method.- Specified by:
createSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
name
- Each similarity measure contains a static field "NAME" that contains the name of the similarity measure, e.g.,SMAggregateAverage.NAME
. If this field does not exist, the similarity measure cannot be instantiated.dataClass
- TheDataClass
for that the similarity measure should be created.- Returns:
- The new
SimilarityMeasure
or null if the name does not relate to a similarity measure or the similarity measure does not fit to the data class
-
registerSimilarityMeasureTemplate
public void registerSimilarityMeasureTemplate(SimilarityMeasure measure) throws NameAlreadyExistsException Add the similarity measure passed to thesimilarityMeasureTemplateCache
. After this model has been initialized, the latter is populated with template objects for each of the standard measures available. Call this method to register an application-specific template.- Specified by:
registerSimilarityMeasureTemplate
in interfaceSimilarityModel
- Throws:
NameAlreadyExistsException
- See Also:
-
getSimilarityMeasures
- Specified by:
getSimilarityMeasures
in interfaceSimilarityModel
- Returns:
- all available similarity measures also including system similarity measures
-
isDefaultSimilarityMeasure
- Specified by:
isDefaultSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
similarityMeasure
- The similarity measure- Returns:
- Returns true, if given measure is defined as default.
-
getSimilarityMeasure
Description copied from interface:SimilarityModel
Returns a suitable similarity measure for the given data class. Default measures are preferred over other suitable measures.- Specified by:
getSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for that a suitableSimilarityMeasure
should be retrieved.- Returns:
- A
SimilarityMeasure
for the given data class.
-
getPossibleSimilarityMeasureFor
Description copied from interface:SimilarityModel
Computes all similarity measure that are possible for the given data class without any order.- Specified by:
getPossibleSimilarityMeasureFor
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for that the availableSimilarityMeasure
s should be retrieved.- Returns:
- An array of available
SimilarityMeasure
names for the given data class.
-
getPossibleSimilarityMeasureFor
Description copied from interface:SimilarityModel
Computes all similarity measure that are possible for the given data class / order combination. This does not includes similarity measures that are also possible without the order.- Specified by:
getPossibleSimilarityMeasureFor
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for that the availableSimilarityMeasure
s should be retrieved.orderName
- The name of the similarity that should be used.- Returns:
- An array of SimilarityMeasure names for the given data class and order.
-
getSimilarityMeasure
- Specified by:
getSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for which the availableSimilarityMeasure
s should be retrieved.name
- The name of the similarity that should be used.- Returns:
- The specified
SimilarityMeasure
-
getSimilarityMeasures
Description copied from interface:SimilarityModel
Retrieves all registeredSimilarityMeasure
s for the givenDataClass
.- Specified by:
getSimilarityMeasures
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for that the registeredSimilarityMeasure
s should be retrieved.- Returns:
- An array of registered
SimilarityMeasure
s for the given data class. IfdataClass
isnull
an empty array will be returned.
-
getSimilarityNamesFor
- Specified by:
getSimilarityNamesFor
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class for that the registeredSimilarityMeasure
names should be retrieved.- Returns:
- An array of names of the registered
SimilarityMeasure
s for the given data class.
-
removeSimilarityMeasure
Description copied from interface:SimilarityModel
Removes the similarity measure with the given name for the given data class.- Specified by:
removeSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
dataClass
- The data class whos similarity measure should be removed.name
- The name of the similarity measure that should be removed.- Returns:
- The removed similarity measure or null if the measure was not found.
-
removeSimilarityMeasure
Description copied from interface:SimilarityModel
Removes the given similarity measure.- Specified by:
removeSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
sm
- The similarity measure that should be removed;- Returns:
- The removed similarity measure or null if the measure was not found.
-
renameSimilarityMeasure
public SimilarityMeasure renameSimilarityMeasure(DataClass dataClass, String oldName, String newName) throws NameAlreadyExistsException, ProCAKENameNotFoundException Description copied from interface:SimilarityModel
Renames an already registeredSimilarityMeasure
. If the defaultSimilarityMeasure
is effected, the default one will be renamed too.- Specified by:
renameSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
dataClass
- The data clas for that the similiarity measure should be renamedoldName
- the old similarity measure namenewName
- the new similarity measure name- Returns:
- the renamed similarity measure
- Throws:
NameAlreadyExistsException
- is thrown if the new name already exists for the data classProCAKENameNotFoundException
- is thrown if now similarity with the old name for the data class can be found.
-
setDefaultSimilarityMeasure
public void setDefaultSimilarityMeasure(DataClass dataClass, String measureName) throws ProCAKENameNotFoundException Description copied from interface:SimilarityModel
TheRetriever
uses in general the defaultSimilarityMeasure
that can be defined with this method. Therefore the data class and the similarity measure name must be defined.- Specified by:
setDefaultSimilarityMeasure
in interfaceSimilarityModel
- Parameters:
dataClass
- TheDataClass
for that the defaultSimilarityMeasure
should be defined.measureName
- The name of theSimilarityMeasure
.- Throws:
ProCAKENameNotFoundException
-
addParameter
Description copied from interface:SimilarityModel
Adds the given name and value to the similarity parameter list. If the name is already used, the previous value will be overwritten with the given value.- Specified by:
addParameter
in interfaceSimilarityModel
- Parameters:
name
- The name of the parametervalue
- The value of the parameter
-
removeParameter
Description copied from interface:SimilarityModel
The parameter with the given name will be removed from the internal parameter-list- Specified by:
removeParameter
in interfaceSimilarityModel
-
getParameter
Description copied from interface:SimilarityModel
The value with the given parameter name will be returned.- Specified by:
getParameter
in interfaceSimilarityModel
- Returns:
- The requested value
-
getAllParameters
Description copied from interface:SimilarityModel
Returns a complete list of all parameters in the system. This is a copy of the internal map, so modifications to this map do not harm the internal map.- Specified by:
getAllParameters
in interfaceSimilarityModel
- Returns:
-