org.electrocodeogram.cpc.classifier.api.strategy
Interface IClassificationStrategy
public interface IClassificationStrategy
API interface for new strategies which want to plug into the CPC Classifier's
IClassificationProvider
implementation.
- Author:
- vw
- See Also:
IClassificationProvider
,
ClassificationProvider
Field Summary |
static java.lang.String |
CLASSIFICATION_REJECT
A special classification which indicates whether the clone should be rejected. |
CLASSIFICATION_REJECT
static final java.lang.String CLASSIFICATION_REJECT
- A special classification which indicates whether the clone should be rejected.
- See Also:
classify(IClassificationProvider.Type, ICloneFile, IClone, String, IClone, Map)
,
Constant Field Values
classify
IClassificationStrategy.Status classify(IClassificationProvider.Type type,
ICloneFile cloneFile,
IClone clone,
java.lang.String fileContent,
IClone originClone,
java.util.Map<java.lang.String,java.lang.Double> result)
- Takes a clone object and the content of the file which contains the clone and
tries to find good classifications for the clone.
A strategy will add its results to the given result map.
The clone object itself is not modified in any way.
Keys of the result map are classification strings as defined in IClassificationProvider
or custom
strings defined by 3rd party plugins.
The values specify the weight of the corresponding classification if an incremental type
is selected, all old classifications are initially added with weight 1.0 to the result map.
Each strategy may increase or decrease the values for any classification, according to its own judgement of
the clone.
After all strategies have been applied, the IClassificationProvider
will keep all classifications with
a weight >0.
The key CLASSIFICATION_REJECT
("cpc.reject") is a special case. Its
value determines whether the clone will be accepted or rejected. The default value is 0.
If the value is >0 after all strategies have been executed, the clone is rejected.
- Parameters:
type
- IClassificationProvider.Type
classification type, never null.cloneFile
- the clone file which contains the clone, must not be modified, never null.clone
- the clone to classify, must not be modified, never null.fileContent
- the content of the corresponding file, never null.originClone
- optional origin clone, may be NULL.result
- a result map with all classifications and their weight,
a strategy writes its results to this map, never null.
- Returns:
- the
IClassificationStrategy.Status
of the strategy execution, never null.