Class ScoreList

java.lang.Object
com.aquima.interactions.matching.result.ScoreList
All Implemented Interfaces:
Serializable

public final class ScoreList extends Object implements 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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    Iterator class that can be used to iterate the values of this list.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScoreList(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 Type
    Method
    Description
    boolean
    addScore(String id, Object key, int score)
    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.
    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
    This method returns a boolean indicating if the list is empty.
    boolean
    This method returns a boolean indicating if the maximum size is reached.
    This method returns an iterator that may be used to traverse over the content of the list.
    This method returns an iterator that may be used to traverse over the scores for a specific key-field value.
    int
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public boolean addScore(String id, Object key, int score)

      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.
    • 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

      public IMatchScore getMatchScore(String id)
      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

      public ScoreList.ScoreIterator 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

      public Collection<Object> 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

      public ScoreList.ScoreIterator iteratorForKey(Object key)
      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.