All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class aid.cbr.tools.core.memory.casebase.FileSimpleCaseBase

java.lang.Object
   |
   +----aid.cbr.tools.core.memory.casebase.AbstractCaseBase
           |
           +----aid.cbr.tools.core.memory.casebase.SimpleCaseBase
                   |
                   +----aid.cbr.tools.core.memory.casebase.FileSimpleCaseBase

public abstract class FileSimpleCaseBase
extends SimpleCaseBase
Implements a simple case base that stores cases with a simple CSV format on a file. The first line a the file defines the metadata of the case base and after each line represents a case. The parsing of these lines are leaved to sub classes by using the Template Method pattern. Thus this classe must be specialized in order to be used and the followin classes must be redefined: This classe provides default implementation of the metadata parsing that creates BasicCaseBaseMetadata objects.

Version:
$Revision$, $Date$
Author:
M. Jaczynski

Constructor Index

 o FileSimpleCaseBase(String, String)
Creates a new case base that stores cases in the given file.
 o FileSimpleCaseBase(String, String, IdentifierGenerator)
Creates a new case base that stores cases in the given file with a specific identifier generator.

Method Index

 o caseToString(CbrCase)
Template Method used to transform a case to line of the file.
 o close()
Closes the case base and write to the file.
 o getFilename()
Returns the filename of the file used to store the case base
 o metadataToString(CaseBaseMetadata)
Template method used to transform a metadata to a line.
 o open(boolean)
Opens the case base in the given mode (readonly or read/write) and reads the file.
 o setFilename(String)
Sets the filename of the file used to store the case base
 o stringToCase(String)
Template Method used to transform a line to a case object.
 o stringToMetadata(String)
Template Method used to transform a line to a metadata object.

Constructors

 o FileSimpleCaseBase
 public FileSimpleCaseBase(String name,
                           String filename)
Creates a new case base that stores cases in the given file.

Parameters:
name - the name of this case base
filename - the filename
 o FileSimpleCaseBase
 public FileSimpleCaseBase(String name,
                           String filename,
                           IdentifierGenerator idGen)
Creates a new case base that stores cases in the given file with a specific identifier generator.

Parameters:
name - the name of this case base
filename - the filename
idGen - the case identifier generator

Methods

 o getFilename
 public String getFilename()
Returns the filename of the file used to store the case base

 o setFilename
 public void setFilename(String filename)
Sets the filename of the file used to store the case base

Parameters:
filename - the filename of the file used to store the case base
 o metadataToString
 protected String metadataToString(CaseBaseMetadata metadata)
Template method used to transform a metadata to a line.

Parameters:
metadata - the metadata
Returns:
the string thats is the first line of the file
 o stringToMetadata
 protected CaseBaseMetadata stringToMetadata(String s) throws CaseBaseAccessException
Template Method used to transform a line to a metadata object.

Parameters:
s - the first line of the file
Returns:
the metadata object
Throws: CaseBaseAccessException
if there is a parsing error
 o caseToString
 protected abstract String caseToString(CbrCase c)
Template Method used to transform a case to line of the file.

Parameters:
c - the case
Returns:
the line representing the case
 o stringToCase
 protected abstract CbrCase stringToCase(String s) throws CaseBaseAccessException
Template Method used to transform a line to a case object.

Parameters:
s - the line from the file
Returns:
the created case
Throws: CaseBaseAccessException
if there is a parsing error
 o close
 public void close() throws CaseBaseAccessException
Closes the case base and write to the file.

Throws: CaseBaseAccessException
the case base cannot be closed.
Overrides:
close in class AbstractCaseBase
 o open
 public void open(boolean readOnly) throws CaseBaseAccessException
Opens the case base in the given mode (readonly or read/write) and reads the file.

Throws: CaseBaseAccessException
the case base cannot be opened.
Overrides:
open in class AbstractCaseBase

All Packages  Class Hierarchy  This Package  Previous  Next  Index