Package weka.core.converters
Class AbstractFileSaver
- java.lang.Object
-
- weka.core.converters.AbstractSaver
-
- weka.core.converters.AbstractFileSaver
-
- All Implemented Interfaces:
java.io.Serializable,CapabilitiesHandler,FileSourcedConverter,Saver,EnvironmentHandler,OptionHandler,RevisionHandler
- Direct Known Subclasses:
ArffSaver,C45Saver,CSVSaver,LibSVMSaver,SerializedInstancesSaver,SVMLightSaver,XRFFSaver
public abstract class AbstractFileSaver extends AbstractSaver implements OptionHandler, FileSourcedConverter, EnvironmentHandler
Abstract class for Savers that save to a file Valid options are: -i input arff file
The input filw in arff format.-o the output file
The output file. The prefix of the output file is sufficient. If no output file is given, Saver tries to use standard out.- Version:
- $Revision: 9023 $
- 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 AbstractFileSaver()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the incremental saving process.java.lang.StringfilePrefix()Gets the file name prefixabstract java.lang.StringgetFileDescription()to be pverriddenjava.lang.StringgetFileExtension()Gets ihe file extension.java.lang.String[]getFileExtensions()Gets all the file extensions used for this type of filejava.lang.String[]getOptions()Gets the current settings of the Saver object.booleangetUseRelativePath()Gets whether relative paths are to be usedjava.io.BufferedWritergetWriter()Gets the writerjava.util.EnumerationlistOptions()Returns an enumeration describing the available options.voidresetOptions()resets the optionsvoidresetWriter()Sets the writer to null.java.lang.StringretrieveDir()Gets the directoryjava.io.FileretrieveFile()Gets the destination file.static voidrunFileSaver(AbstractFileSaver saver, java.lang.String[] options)runs the given saver with the specified optionsvoidsetDestination(java.io.File file)Sets the destination file (and directories if necessary).voidsetDestination(java.io.OutputStream output)Sets the destination output stream.voidsetDir(java.lang.String dir)Sets the directory where the instances should be storedvoidsetDirAndPrefix(java.lang.String relationName, java.lang.String add)Sets the directory and the file prefix.voidsetEnvironment(Environment env)Set the environment variables to use.voidsetFile(java.io.File outputFile)Sets the destination file.voidsetFilePrefix(java.lang.String prefix)Sets the file name prefixvoidsetOptions(java.lang.String[] options)Parses a given list of options.voidsetUseRelativePath(boolean rp)Set whether to use relative rather than absolute pathsjava.lang.StringuseRelativePathTipText()Tip text suitable for displaying int the GUI-
Methods inherited from class weka.core.converters.AbstractSaver
getCapabilities, getInstances, getWriteMode, resetStructure, setInstances, setRetrieval, setStructure, writeBatch, writeIncremental
-
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- Overrides:
resetOptionsin classAbstractSaver
-
getWriter
public java.io.BufferedWriter getWriter()
Gets the writer- Returns:
- the BufferedWriter
-
resetWriter
public void resetWriter()
Sets the writer to null.
-
getFileExtension
public java.lang.String getFileExtension()
Gets ihe file extension.- Specified by:
getFileExtensionin interfaceFileSourcedConverter- Specified by:
getFileExtensionin interfaceSaver- Overrides:
getFileExtensionin classAbstractSaver- Returns:
- the file extension as a string.
-
getFileExtensions
public java.lang.String[] getFileExtensions()
Gets all the file extensions used for this type of file- Specified by:
getFileExtensionsin interfaceFileSourcedConverter- Returns:
- the file extensions
-
retrieveFile
public java.io.File retrieveFile()
Gets the destination file.- Specified by:
retrieveFilein interfaceFileSourcedConverter- Returns:
- the destination file.
-
setFile
public void setFile(java.io.File outputFile) throws java.io.IOExceptionSets the destination file.- Specified by:
setFilein interfaceFileSourcedConverter- Specified by:
setFilein interfaceSaver- Overrides:
setFilein classAbstractSaver- Parameters:
outputFile- the destination file.- Throws:
java.io.IOException- throws an IOException if file cannot be set
-
setFilePrefix
public void setFilePrefix(java.lang.String prefix)
Sets the file name prefix- Specified by:
setFilePrefixin interfaceSaver- Overrides:
setFilePrefixin classAbstractSaver- Parameters:
prefix- the file name prefix
-
filePrefix
public java.lang.String filePrefix()
Gets the file name prefix- Specified by:
filePrefixin interfaceSaver- Overrides:
filePrefixin classAbstractSaver- Returns:
- the prefix of the filename
-
setDir
public void setDir(java.lang.String dir)
Sets the directory where the instances should be stored- Specified by:
setDirin interfaceSaver- Overrides:
setDirin classAbstractSaver- Parameters:
dir- a string containing the directory path and name
-
retrieveDir
public java.lang.String retrieveDir()
Gets the directory- Specified by:
retrieveDirin interfaceSaver- Overrides:
retrieveDirin classAbstractSaver- Returns:
- a string with the file name
-
setEnvironment
public void setEnvironment(Environment env)
Set the environment variables to use.- Specified by:
setEnvironmentin interfaceEnvironmentHandler- Parameters:
env- the environment variables to use
-
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all the available options.
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options. Valid option is:-i input arff file
The input filw in arff format.-o the output file
The output file. The prefix of the output file is sufficient. If no output file is given, Saver tries to use standard out.- Specified by:
setOptionsin interfaceOptionHandler- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the Saver object.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- an array of strings suitable for passing to setOptions
-
cancel
public void cancel()
Cancels the incremental saving process.- Overrides:
cancelin classAbstractSaver
-
setDestination
public void setDestination(java.io.File file) throws java.io.IOExceptionSets the destination file (and directories if necessary).- Specified by:
setDestinationin interfaceSaver- Overrides:
setDestinationin classAbstractSaver- Parameters:
file- the File- Throws:
java.io.IOException- always
-
setDestination
public void setDestination(java.io.OutputStream output) throws java.io.IOExceptionSets the destination output stream.- Specified by:
setDestinationin interfaceSaver- Overrides:
setDestinationin classAbstractSaver- Parameters:
output- the output stream.- Throws:
java.io.IOException- throws an IOException if destination cannot be set
-
setDirAndPrefix
public void setDirAndPrefix(java.lang.String relationName, java.lang.String add)Sets the directory and the file prefix. This method is used in the KnowledgeFlow GUI- Specified by:
setDirAndPrefixin interfaceSaver- Overrides:
setDirAndPrefixin classAbstractSaver- Parameters:
relationName- the name of the relation to saveadd- additional string which should be part of the filename
-
getFileDescription
public abstract java.lang.String getFileDescription()
to be pverridden- Specified by:
getFileDescriptionin interfaceFileSourcedConverter- Returns:
- the file type description.
-
useRelativePathTipText
public java.lang.String useRelativePathTipText()
Tip text suitable for displaying int the GUI- Returns:
- a description of this property as a String
-
setUseRelativePath
public void setUseRelativePath(boolean rp)
Set whether to use relative rather than absolute paths- Specified by:
setUseRelativePathin interfaceFileSourcedConverter- Parameters:
rp- true if relative paths are to be used
-
getUseRelativePath
public boolean getUseRelativePath()
Gets whether relative paths are to be used- Specified by:
getUseRelativePathin interfaceFileSourcedConverter- Returns:
- true if relative paths are to be used
-
runFileSaver
public static void runFileSaver(AbstractFileSaver saver, java.lang.String[] options)
runs the given saver with the specified options- Parameters:
saver- the saver to runoptions- the commandline options
-
-