Class CaseLibrary

java.lang.Object
  |
  +--CaseLibrary
All Implemented Interfaces:
java.io.Serializable

public class CaseLibrary
extends java.lang.Object
implements java.io.Serializable

The class `CaseLibrary' represents a case library. It encapsulates an organisation of cases within the library, allowing new cases to be added and existing cases to be retrieved.

See Also:
Serialized Form

Constructor Summary
CaseLibrary()
           
 
Method Summary
 void insert(Case newCase)
          Adds a new case in the case library.
static void load(java.lang.String filename)
          Loads the case library from a binary file.
 void print()
          Prints the contents of the case library, in the form of a list of cases (frame reference and filename for each case) for each frame class in the library's index.
 java.util.Vector retrieve(Frame prompt)
          Retrieves those cases from the case library that are indexed by the frame class of the prompt frame, without full matching.
 Case retrieveOneMatchingCase(Frame prompt)
          Retrieves one case from the case library that fully matches the prompt frame.
static void save(java.lang.String filename)
          Saves the case library to a binary file.
static Case selectMostSpecific(java.util.Vector cases)
          Given a set of cases, select the one which is the most specific - i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaseLibrary

public CaseLibrary()
Method Detail

retrieve

public java.util.Vector retrieve(Frame prompt)
Retrieves those cases from the case library that are indexed by the frame class of the prompt frame, without full matching.
Parameters:
prompt - A frame to use as a retrieval prompt.
Returns:
The set of cases which the prompt reminds the CBR system of.

retrieveOneMatchingCase

public Case retrieveOneMatchingCase(Frame prompt)
Retrieves one case from the case library that fully matches the prompt frame. If it finds such a case, it returns it immediately, without continuing to see if there are any more (there shouldn't be, by construction).
Parameters:
prompt - A frame to use as a retrieval prompt.
Returns:
One case that fully matches the prompt frame, or null if no such case is retrieved.

selectMostSpecific

public static Case selectMostSpecific(java.util.Vector cases)
Given a set of cases, select the one which is the most specific - i.e. whose `problem' frame class is a subclass of all the others'.
Parameters:
cases - A non-empty set of cases.
Returns:
The most specific case in the set.

insert

public void insert(Case newCase)
Adds a new case in the case library. Indexes it by the frame class of the frame in its "problem" slot, and by all the subclasses of that frame class (so that it will be retrieved for prompt frames which are instances of the subclasses).
Parameters:
case - The new case to store in the case library.

load

public static void load(java.lang.String filename)
                 throws java.io.FileNotFoundException
Loads the case library from a binary file.
Parameters:
filename - The filename of the case library binary.
Throws:
java.io.FileNotFoundException - If the file is not found.

save

public static void save(java.lang.String filename)
Saves the case library to a binary file.
Parameters:
filename - The filename of the case library binary.

print

public void print()
Prints the contents of the case library, in the form of a list of cases (frame reference and filename for each case) for each frame class in the library's index.