Class ScoreList
java.lang.Object
com.aquima.interactions.matching.result.ScoreList
- All Implemented Interfaces:
Serializable
This object stores the match scores and makes sure the number of scores stays within the given limits.
Copyright: Copyright (c) 2002
Company: Everest b.v.
- Since:
- 1.0
- Author:
- O. Kerpershoek
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Iterator class that can be used to iterate the values of this list. -
Constructor Summary
ConstructorsConstructorDescriptionScoreList
(int maxResults, int threshold) Constructs the score list without key field grouping.ScoreList
(int maxResults, int threshold, boolean useKeyField) Constructs the score list with key field grouping and a single result for each key-field.ScoreList
(int maxResults, int threshold, boolean useKeyField, int maxKeyFieldResults) Constructs the score list with key field grouping. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method will add the score for the given id and key combination.int
This method returns the highest score that is currently present in the list.int
This method returns the lowest score that is currently present in the list.getMatchScore
(String id) This method returns the match score for the specified ID.int
This method returns the maximum size that is allowed for this list.protected int
boolean
isEmpty()
This method returns a boolean indicating if the list is empty.boolean
isFull()
This method returns a boolean indicating if the maximum size is reached.iterator()
This method returns an iterator that may be used to traverse over the content of the list.iteratorForKey
(Object key) This method returns an iterator that may be used to traverse over the scores for a specific key-field value.int
size()
This method returns the actual size of the list.This method returns the list of unique key's that were added to this score list instance.
-
Constructor Details
-
ScoreList
public ScoreList(int maxResults, int threshold) Constructs the score list without key field grouping.- Parameters:
maxResults
- The maximum number of results that may be present in the list.threshold
- The minimum score a result should have in order to be included in the list.
-
ScoreList
public ScoreList(int maxResults, int threshold, boolean useKeyField) Constructs the score list with key field grouping and a single result for each key-field.- Parameters:
maxResults
- The maximum number of results that may be present in the list.threshold
- The minimum score a result should have in order to be included in the list.useKeyField
- Boolean indicating if key-field grouping should be used.
-
ScoreList
public ScoreList(int maxResults, int threshold, boolean useKeyField, int maxKeyFieldResults) Constructs the score list with key field grouping.- Parameters:
maxResults
- The maximum number of results that may be present in the list.threshold
- The minimum score a result should have in order to be included in the list.useKeyField
- Boolean indicating if key-field grouping should be used.maxKeyFieldResults
- The number of results that should be grouped under a single key field value.
-
-
Method Details
-
addScore
This method will add the score for the given id and key combination. The score is added when the following conditions are met:
- When the score is lower than the lowest score yet:
- The maximum size has not been reached
- The maximum size for the given key has not been reached.
- When the score is higher than the lowest score yet:
Note: The key is only used if this class has been constructed with the parameter useKeyField true.
- Parameters:
id
- The ID of the case for which the score is added.key
- The key-field object the score should be grouped on (optional)score
- The score of the case.- Returns:
- A boolean indicating if the score was actually added.
- When the score is lower than the lowest score yet:
-
getMaximumSize
public int getMaximumSize()This method returns the maximum size that is allowed for this list.- Returns:
- the maximum size that is allowed for this list.
-
getThreshold
protected int getThreshold() -
size
public int size()This method returns the actual size of the list.- Returns:
- the actual size of the list.
-
getMatchScore
This method returns the match score for the specified ID.- Parameters:
id
- The ID for which the score is requested.- Returns:
- the match score for the specified ID.
-
isEmpty
public boolean isEmpty()This method returns a boolean indicating if the list is empty.- Returns:
- a boolean indicating if the list is empty.
-
isFull
public boolean isFull()This method returns a boolean indicating if the maximum size is reached. When the list is full, new scores may still be added, but they will either replace existing scores or not be added.- Returns:
- a boolean indicating if the maximum size is reached.
-
getHighestScore
public int getHighestScore()This method returns the highest score that is currently present in the list.- Returns:
- the highest score that is currently present in the list.
-
getLowestScore
public int getLowestScore()This method returns the lowest score that is currently present in the list.- Returns:
- the lowest score that is currently present in the list.
-
iterator
This method returns an iterator that may be used to traverse over the content of the list. The iterator will return the highest match score first.- Returns:
- an iterator that may be used to traverse over the content of the list.
-
uniqueKeys
This method returns the list of unique key's that were added to this score list instance. This method will only return keys if the useKeyField parameter of the constructor was true.
Note: The collection might contain a null pointer, indicating there were scores added without a key !
- Returns:
- A collection of unique keys that were added to this score list instance.
-
iteratorForKey
This method returns an iterator that may be used to traverse over the scores for a specific key-field value. The iterator will return the highest match score first. Note: When no results are present for the specified key value, this method will return null.- Parameters:
key
- The key field value for which the scores are requested.- Returns:
- an iterator that may be used to traverse over the scores for a specific key-field value.
-