Package weka.core.converters

# Interface Saver

All Superinterfaces:
  `RevisionHandler`, `Serializable`

All Known Implementing Classes:
  `AbstractFileSaver`, `AbstractSaver`, `ArffSaver`, `C45Saver`, `CSVSaver`, `DatabaseSaver`, `DictionarySaver`, `JSONSaver`, `LibSVMSaver`, `MatlabSaver`, `SerializedInstancesSaver`, `SVMLightSaver`, `XRFFSaver`

public interface Saver extends Serializable, RevisionHandler
Interface to something that can save Instances to an output destination in some format.

Version:
  $Revision: 8034 $
Author:
  Mark Hall (mhall@cs.waikato.ac.nz), Stefan Mutter (mutter@cs.waikato.ac.nz)

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `BATCH`
  `static final int`
  `INCREMENTAL`
  `static final int`
  `NONE`
  The retrieval modes

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `filePrefix()`
  Gets the file prefix This method is used in the KnowledgeFlow GUI.
  `String`
  `getFileExtension()`
  Gets the file extension
  `int`
  `getWriteMode()`
  Gets the write mode
  `String`
  `retrieveDir()`
  Gets the driectory of the output file This method is used in the KnowledgeFlow GUI.
  `void`
  `setDestination(File file)`
  Resets the Saver object and sets the destination to be the supplied File object.
  `void`
  `setDestination(OutputStream output)`
  Resets the Saver object and sets the destination to be the supplied InputStream.
  `void`
  `setDir(String dir)`
  Sets the directory of the output file.
  `void`
  `setDirAndPrefix(String relationName, String add)`
  Sets the file prefix and the directory.
  `void`
  `setFile(File file)`
  Sets the output file
  `void`
  `setFilePrefix(String prefix)`
  Sets the file prefix.
  `void`
  `setInstances(Instances instances)`
  Sets the instances to be saved
  `void`
  `setRetrieval(int mode)`
  Sets the retrieval mode
  `void`
  `writeBatch()`
  Writes to a destination in batch mode
  `void`
  `writeIncremental(Instance inst)`
  Writes to a destination in incremental mode.

  ### Methods inherited from interface weka.core.RevisionHandler

  `getRevision`

- ## Field Details

  - ### NONE

    static final int NONE
    The retrieval modes
    See Also:
      - Constant Field Values

  - ### BATCH

    static final int BATCH
    See Also:
      - Constant Field Values

  - ### INCREMENTAL

    static final int INCREMENTAL
    See Also:
      - Constant Field Values

- ## Method Details

  - ### setDestination

    void setDestination(File file) throws IOException
    Resets the Saver object and sets the destination to be the supplied File object.
    Parameters:
      `file` - the File
    Throws:
      `IOException` - if an error occurs support loading from a File.

              public_normal_behavior
                requires: file != null
                          && (* file exists *);
                modifiable: model_sourceSupplied, model_structureDetermined;
                ensures: model_sourceSupplied == true
                         && model_structureDetermined == false;
            also
              public_exceptional_behavior
                requires: file == null
                          || (* file does not exist *);
              signals: (IOException);

  - ### setDestination

    void setDestination(OutputStream output) throws IOException
    Resets the Saver object and sets the destination to be the supplied InputStream.
    Parameters:
      `output` - the output stream
    Throws:
      `IOException` - if this Loader doesn't support loading from a File.

  - ### setRetrieval

    void setRetrieval(int mode)
    Sets the retrieval mode
    Parameters:
      `mode` - an integer representing a retrieval mode

  - ### getFileExtension

    String getFileExtension() throws Exception
    Gets the file extension
    Returns:
      a string conatining the file extension (including the '.')
    Throws:
      `Exception` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### setFile

    void setFile(File file) throws IOException
    Sets the output file
    Parameters:
      `file` - the output file
    Throws:
      `IOException` - exception if new output file cannot be set

  - ### setFilePrefix

    void setFilePrefix(String prefix) throws Exception
    Sets the file prefix. This method is used in the KnowledgeFlow GUI.
    Parameters:
      `prefix` - the prefix of the file name
    Throws:
      `Exception` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### filePrefix

    String filePrefix() throws Exception
    Gets the file prefix This method is used in the KnowledgeFlow GUI.
    Returns:
      the prefix of the file name
    Throws:
      `Exception` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### setDir

    void setDir(String dir) throws IOException
    Sets the directory of the output file. This method is used in the KnowledgeFlow GUI.
    Parameters:
      `dir` - a string containing the path and name of the directory
    Throws:
      `IOException` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### setDirAndPrefix

    void setDirAndPrefix(String relationName, String add) throws IOException
    Sets the file prefix and the directory. This method is used in the KnowledgeFlow GUI.
    Parameters:
      `relationName` - the name of the realtion to be saved
      `add` - additional String for the file name
    Throws:
      `IOException` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### retrieveDir

    String retrieveDir() throws IOException
    Gets the driectory of the output file This method is used in the KnowledgeFlow GUI.
    Returns:
      the directory as a string
    Throws:
      `IOException` - exception if a Saver not implementing FileSourcedConverter is used.

  - ### setInstances

    void setInstances(Instances instances)
    Sets the instances to be saved
    Parameters:
      `instances` - the instances

  - ### writeBatch

    void writeBatch() throws IOException
    Writes to a destination in batch mode
    Throws:
      `IOException` - throws exection if writting in batch mode is not possible

  - ### writeIncremental

    void writeIncremental(Instance inst) throws IOException
    Writes to a destination in incremental mode. If the instance is null, the outputfile will be closed.
    Parameters:
      `inst` - the instance to write, if null the output file is closed
    Throws:
      `IOException` - throws exception if incremental writting is not possible

  - ### getWriteMode

    int getWriteMode()
    Gets the write mode
    Returns:
      an integer representing the write mode