public class PlainTextConnector extends Object implements Connector
Implements a generic PlainText Connector.
It manages the persistence of the cases automatically into textual files. Features:This connector uses the property in the initFromXMLfile() parameter to obtain the configuration file. This file is a xml that follows the Schema defined in /doc/configfilesSchemas/PlainTextConnector.xsd:
This class does not implement any cache mechanims, so cases are read and written directly. This can be very inefficient in some operations (mainly in reading)
Some methods will fail when executing the connector with a case base file inside a jar file. The retrieve() methods will work properly but the methods that write in the file will fail. Extract the file to the file system and run the connector with that location to solve these problems.
For an example see Test6.
PlainTextTypeConverter,
TypeAdaptor| Modifier and Type | Field and Description |
|---|---|
protected String |
PROP_DELIM |
protected String |
PROP_FILEPATH |
| Constructor and Description |
|---|
PlainTextConnector() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Cleanup any resource that the connector might be using, and suspends the
service
|
void |
deleteCases(Collection<CBRCase> cases)
Deletes cases from the case base.
|
void |
initFromXMLfile(URL file)
Initialices the connector with the given XML file
|
List<CBRCase> |
retrieveAllCases()
Retrieves all cases from the text file.
|
List<CBRCase> |
retrieveSomeCases(CaseBaseFilter filter)
Retrieves some cases depending on the filter.
|
void |
storeCases(Collection<CBRCase> cases)
Stores the cases in the data base.
|
protected String PROP_FILEPATH
protected String PROP_DELIM
public PlainTextConnector()
public void initFromXMLfile(URL file) throws InitializingException
ConnectorinitFromXMLfile in interface Connectorfile - XMl file with the settingsInitializingException - Raised if the connector can not be initialezed.public void close()
Connectorpublic void storeCases(Collection<CBRCase> cases)
storeCases in interface Connectorcases - Cases to store.Exceptionpublic void deleteCases(Collection<CBRCase> cases)
deleteCases in interface Connectorcases - Cases to deletepublic List<CBRCase> retrieveAllCases()
retrieveAllCases in interface Connectorpublic List<CBRCase> retrieveSomeCases(CaseBaseFilter filter)
ConnectorretrieveSomeCases in interface ConnectorCopyright © 2018 Group of Artificial Intelligence Applications (GAIA). All rights reserved.