Package weka.core.converters
Class AbstractSaver
- java.lang.Object
-
- weka.core.converters.AbstractSaver
-
- All Implemented Interfaces:
java.io.Serializable,CapabilitiesHandler,Saver,RevisionHandler
- Direct Known Subclasses:
AbstractFileSaver,DatabaseSaver
public abstract class AbstractSaver extends java.lang.Object implements Saver, CapabilitiesHandler
Abstract class for Saver- Version:
- $Revision: 1.4 $
- Author:
- Richard Kirkby (rkirkby@cs.waikato.ac.nz), Stefan Mutter (mutter@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface weka.core.converters.Saver
BATCH, INCREMENTAL, NONE
-
-
Constructor Summary
Constructors Constructor Description AbstractSaver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the incremental saving process if the write mode is CANCEL.java.lang.StringfilePrefix()Default implementation throws an IOException.CapabilitiesgetCapabilities()Returns the Capabilities of this saver.java.lang.StringgetFileExtension()Default implementation throws an IOException.InstancesgetInstances()Gets instances that should be stored.intgetWriteMode()Gets the write mode.voidresetOptions()resets the optionsvoidresetStructure()Resets the structure (header information of the instances)java.lang.StringretrieveDir()Default implementation throws an IOException.voidsetDestination(java.io.File file)Default implementation throws an IOException.voidsetDestination(java.io.OutputStream output)Default implementation throws an IOException.voidsetDir(java.lang.String dir)Default implementation throws an IOException.voidsetDirAndPrefix(java.lang.String relationName, java.lang.String add)Default implementation throws an IOException.voidsetFile(java.io.File file)Default implementation throws an IOException.voidsetFilePrefix(java.lang.String prefix)Default implementation throws an IOException.voidsetInstances(Instances instances)Sets instances that should be stored.voidsetRetrieval(int mode)Sets the retrieval mode.intsetStructure(Instances headerInfo)Sets the strcuture of the instances for the first step of incremental saving.abstract voidwriteBatch()Writes to a file in batch mode To be overridden.voidwriteIncremental(Instance i)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
-
-
-
-
Method Detail
-
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:
setRetrievalin interfaceSaver- Parameters:
mode- the retrieval mode
-
getWriteMode
public int getWriteMode()
Gets the write mode.- Specified by:
getWriteModein interfaceSaver- Returns:
- the write mode
-
setInstances
public void setInstances(Instances instances)
Sets instances that should be stored.- Specified by:
setInstancesin interfaceSaver- Parameters:
instances- the instances
-
getInstances
public Instances getInstances()
Gets instances that should be stored.- Returns:
- the instances
-
setDestination
public void setDestination(java.io.File file) throws java.io.IOExceptionDefault implementation throws an IOException.- Specified by:
setDestinationin interfaceSaver- Parameters:
file- the File- Throws:
java.io.IOException- always
-
setDestination
public void setDestination(java.io.OutputStream output) throws java.io.IOExceptionDefault implementation throws an IOException.- Specified by:
setDestinationin interfaceSaver- Parameters:
output- the OutputStream- Throws:
java.io.IOException- always
-
getCapabilities
public Capabilities getCapabilities()
Returns the Capabilities of this saver. Derived savers have to override this method to enable capabilities.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
setStructure
public int setStructure(Instances headerInfo)
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
public void writeIncremental(Instance i) throws java.io.IOException
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:
writeIncrementalin interfaceSaver- Parameters:
i- the instance to be saved- Throws:
java.io.IOException- IOEXception if the instance acnnot be written to the specified destination
-
writeBatch
public abstract void writeBatch() throws java.io.IOExceptionWrites to a file in batch mode To be overridden.- Specified by:
writeBatchin interfaceSaver- Throws:
java.io.IOException- exception if writting is not possible
-
getFileExtension
public java.lang.String getFileExtension() throws java.lang.ExceptionDefault implementation throws an IOException.- Specified by:
getFileExtensionin interfaceSaver- Returns:
- a string conatining the file extension (including the '.')
- Throws:
java.io.IOException- alwaysjava.lang.Exception- exception if a Saver not implementing FileSourcedConverter is used.
-
setFile
public void setFile(java.io.File file) throws java.io.IOExceptionDefault implementation throws an IOException.
-
setFilePrefix
public void setFilePrefix(java.lang.String prefix) throws java.lang.ExceptionDefault implementation throws an IOException.- Specified by:
setFilePrefixin interfaceSaver- Parameters:
prefix- the file prefix- Throws:
java.io.IOException- alwaysjava.lang.Exception- exception if a Saver not implementing FileSourcedConverter is used.
-
filePrefix
public java.lang.String filePrefix() throws java.lang.ExceptionDefault implementation throws an IOException.- Specified by:
filePrefixin interfaceSaver- Returns:
- the prefix of the file name
- Throws:
java.io.IOException- alwaysjava.lang.Exception- exception if a Saver not implementing FileSourcedConverter is used.
-
setDir
public void setDir(java.lang.String dir) throws java.io.IOExceptionDefault implementation throws an IOException.
-
setDirAndPrefix
public void setDirAndPrefix(java.lang.String relationName, java.lang.String add) throws java.io.IOExceptionDefault implementation throws an IOException.- Specified by:
setDirAndPrefixin interfaceSaver- Parameters:
relationName-add-- Throws:
java.io.IOException- always
-
retrieveDir
public java.lang.String retrieveDir() throws java.io.IOExceptionDefault implementation throws an IOException.- Specified by:
retrieveDirin interfaceSaver- Returns:
- the directory as a string
- Throws:
java.io.IOException- always
-
-