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:
metadataToString
stringToMetadata
caseToString
stringToCase
This classe provides default implementation of the metadata parsing that creates
BasicCaseBaseMetadata
objects.
- Version:
- $Revision$, $Date$
- Author:
- M. Jaczynski
-
FileSimpleCaseBase(String, String)
- Creates a new case base that stores cases in the given file.
-
FileSimpleCaseBase(String, String, IdentifierGenerator)
- Creates a new case base that stores cases in the given file with a specific identifier generator.
-
caseToString(CbrCase)
- Template Method used to transform a case to line of the file.
-
close()
- Closes the case base and write to the file.
-
getFilename()
- Returns the filename of the file used to store the case base
-
metadataToString(CaseBaseMetadata)
- Template method used to transform a metadata to a line.
-
open(boolean)
- Opens the case base in the given mode (readonly or read/write) and reads the file.
-
setFilename(String)
- Sets the filename of the file used to store the case base
-
stringToCase(String)
- Template Method used to transform a line to a case object.
-
stringToMetadata(String)
- Template Method used to transform a line to a metadata object.
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
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
getFilename
public String getFilename()
- Returns the filename of the file used to store the case base
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
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
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
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
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
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
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