Package weka.core.converters
Class AbstractSaver
java.lang.Object
weka.core.converters.AbstractSaver
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,CapabilitiesIgnorer
,Saver
,RevisionHandler
- Direct Known Subclasses:
AbstractFileSaver
,DatabaseSaver
public abstract class AbstractSaver
extends Object
implements Saver, CapabilitiesHandler, CapabilitiesIgnorer
Abstract class for Saver
- Version:
- $Revision: 11006 $
- Author:
- Richard Kirkby (rkirkby@cs.waikato.ac.nz), Stefan Mutter (mutter@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Fields inherited from interface weka.core.converters.Saver
BATCH, INCREMENTAL, NONE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the incremental saving process if the write mode is CANCEL.Returns the tip text for this propertyDefault implementation throws an IOException.Returns the Capabilities of this saver.boolean
Get whether capabilities checking is turned off.Default implementation throws an IOException.Gets instances that should be stored.int
Gets the write mode.void
resets the optionsvoid
Resets the structure (header information of the instances)Default implementation throws an IOException.void
setDestination
(File file) Default implementation throws an IOException.void
setDestination
(OutputStream output) Default implementation throws an IOException.void
Default implementation throws an IOException.void
setDirAndPrefix
(String relationName, String add) Default implementation throws an IOException.void
setDoNotCheckCapabilities
(boolean doNotCheckCapabilities) Set whether not to check capabilities.void
Default implementation throws an IOException.void
setFilePrefix
(String prefix) Default implementation throws an IOException.void
setInstances
(Instances instances) Sets instances that should be stored.void
setRetrieval
(int mode) Sets the retrieval mode.int
setStructure
(Instances headerInfo) Sets the strcuture of the instances for the first step of incremental saving.abstract void
Writes to a file in batch mode To be overridden.void
Method for incremental saving.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface weka.core.RevisionHandler
getRevision
-
Constructor Details
-
AbstractSaver
public AbstractSaver()
-
-
Method Details
-
doNotCheckCapabilitiesTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setDoNotCheckCapabilities
public void setDoNotCheckCapabilities(boolean doNotCheckCapabilities) Set whether not to check capabilities.- Specified by:
setDoNotCheckCapabilities
in interfaceCapabilitiesIgnorer
- Parameters:
doNotCheckCapabilities
- true if capabilities are not to be checked.
-
getDoNotCheckCapabilities
public boolean getDoNotCheckCapabilities()Get whether capabilities checking is turned off.- Specified by:
getDoNotCheckCapabilities
in interfaceCapabilitiesIgnorer
- Returns:
- true if capabilities checking is turned off.
-
resetOptions
public void resetOptions()resets the options -
resetStructure
public void resetStructure()Resets the structure (header information of the instances) -
setRetrieval
public void setRetrieval(int mode) Sets the retrieval mode.- Specified by:
setRetrieval
in interfaceSaver
- Parameters:
mode
- the retrieval mode
-
getWriteMode
public int getWriteMode()Gets the write mode.- Specified by:
getWriteMode
in interfaceSaver
- Returns:
- the write mode
-
setInstances
Sets instances that should be stored.- Specified by:
setInstances
in interfaceSaver
- Parameters:
instances
- the instances
-
getInstances
Gets instances that should be stored.- Returns:
- the instances
-
setDestination
Default implementation throws an IOException.- Specified by:
setDestination
in interfaceSaver
- Parameters:
file
- the File- Throws:
IOException
- always
-
setDestination
Default implementation throws an IOException.- Specified by:
setDestination
in interfaceSaver
- Parameters:
output
- the OutputStream- Throws:
IOException
- always
-
getCapabilities
Returns the Capabilities of this saver. Derived savers have to override this method to enable capabilities.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Returns:
- the capabilities of this object
- See Also:
-
setStructure
Sets the strcuture of the instances for the first step of incremental saving. The instances only need to have a header.- Parameters:
headerInfo
- an instances object.- Returns:
- the appropriate write mode
-
cancel
public void cancel()Cancels the incremental saving process if the write mode is CANCEL. -
writeIncremental
Method for incremental saving. Standard behaviour: no incremental saving is possible, therefore throw an IOException. An incremental saving process is stopped by calling this method with null.- Specified by:
writeIncremental
in interfaceSaver
- Parameters:
i
- the instance to be saved- Throws:
IOException
- IOEXception if the instance acnnot be written to the specified destination
-
writeBatch
Writes to a file in batch mode To be overridden.- Specified by:
writeBatch
in interfaceSaver
- Throws:
IOException
- exception if writting is not possible
-
getFileExtension
Default implementation throws an IOException.- Specified by:
getFileExtension
in interfaceSaver
- Returns:
- a string conatining the file extension (including the '.')
- Throws:
IOException
- alwaysException
- exception if a Saver not implementing FileSourcedConverter is used.
-
setFile
Default implementation throws an IOException.- Specified by:
setFile
in interfaceSaver
- Parameters:
file
- the File- Throws:
IOException
- always
-
setFilePrefix
Default implementation throws an IOException.- Specified by:
setFilePrefix
in interfaceSaver
- Parameters:
prefix
- the file prefix- Throws:
IOException
- alwaysException
- exception if a Saver not implementing FileSourcedConverter is used.
-
filePrefix
Default implementation throws an IOException.- Specified by:
filePrefix
in interfaceSaver
- Returns:
- the prefix of the file name
- Throws:
IOException
- alwaysException
- exception if a Saver not implementing FileSourcedConverter is used.
-
setDir
Default implementation throws an IOException.- Specified by:
setDir
in interfaceSaver
- Parameters:
dir
- the name of the directory to save in- Throws:
IOException
- always
-
setDirAndPrefix
Default implementation throws an IOException.- Specified by:
setDirAndPrefix
in interfaceSaver
- Parameters:
relationName
-add
-- Throws:
IOException
- always
-
retrieveDir
Default implementation throws an IOException.- Specified by:
retrieveDir
in interfaceSaver
- Returns:
- the directory as a string
- Throws:
IOException
- always
-