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:
  • Constructor Details

    • AbstractSaver

      public AbstractSaver()
  • Method Details

    • doNotCheckCapabilitiesTipText

      public String 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 interface CapabilitiesIgnorer
      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 interface CapabilitiesIgnorer
      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 interface Saver
      Parameters:
      mode - the retrieval mode
    • getWriteMode

      public int getWriteMode()
      Gets the write mode.
      Specified by:
      getWriteMode in interface Saver
      Returns:
      the write mode
    • setInstances

      public void setInstances(Instances instances)
      Sets instances that should be stored.
      Specified by:
      setInstances in interface Saver
      Parameters:
      instances - the instances
    • getInstances

      public Instances getInstances()
      Gets instances that should be stored.
      Returns:
      the instances
    • setDestination

      public void setDestination(File file) throws IOException
      Default implementation throws an IOException.
      Specified by:
      setDestination in interface Saver
      Parameters:
      file - the File
      Throws:
      IOException - always
    • setDestination

      public void setDestination(OutputStream output) throws IOException
      Default implementation throws an IOException.
      Specified by:
      setDestination in interface Saver
      Parameters:
      output - the OutputStream
      Throws:
      IOException - always
    • getCapabilities

      public Capabilities getCapabilities()
      Returns the Capabilities of this saver. Derived savers have to override this method to enable capabilities.
      Specified by:
      getCapabilities in interface CapabilitiesHandler
      Returns:
      the capabilities of this object
      See Also:
    • 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 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:
      writeIncremental in interface Saver
      Parameters:
      i - the instance to be saved
      Throws:
      IOException - IOEXception if the instance acnnot be written to the specified destination
    • writeBatch

      public abstract void writeBatch() throws IOException
      Writes to a file in batch mode To be overridden.
      Specified by:
      writeBatch in interface Saver
      Throws:
      IOException - exception if writting is not possible
    • getFileExtension

      public String getFileExtension() throws Exception
      Default implementation throws an IOException.
      Specified by:
      getFileExtension in interface Saver
      Returns:
      a string conatining the file extension (including the '.')
      Throws:
      IOException - always
      Exception - exception if a Saver not implementing FileSourcedConverter is used.
    • setFile

      public void setFile(File file) throws IOException
      Default implementation throws an IOException.
      Specified by:
      setFile in interface Saver
      Parameters:
      file - the File
      Throws:
      IOException - always
    • setFilePrefix

      public void setFilePrefix(String prefix) throws Exception
      Default implementation throws an IOException.
      Specified by:
      setFilePrefix in interface Saver
      Parameters:
      prefix - the file prefix
      Throws:
      IOException - always
      Exception - exception if a Saver not implementing FileSourcedConverter is used.
    • filePrefix

      public String filePrefix() throws Exception
      Default implementation throws an IOException.
      Specified by:
      filePrefix in interface Saver
      Returns:
      the prefix of the file name
      Throws:
      IOException - always
      Exception - exception if a Saver not implementing FileSourcedConverter is used.
    • setDir

      public void setDir(String dir) throws IOException
      Default implementation throws an IOException.
      Specified by:
      setDir in interface Saver
      Parameters:
      dir - the name of the directory to save in
      Throws:
      IOException - always
    • setDirAndPrefix

      public void setDirAndPrefix(String relationName, String add) throws IOException
      Default implementation throws an IOException.
      Specified by:
      setDirAndPrefix in interface Saver
      Parameters:
      relationName -
      add -
      Throws:
      IOException - always
    • retrieveDir

      public String retrieveDir() throws IOException
      Default implementation throws an IOException.
      Specified by:
      retrieveDir in interface Saver
      Returns:
      the directory as a string
      Throws:
      IOException - always