weka.core.converters
Class AbstractLoader
java.lang.Object
|
+--weka.core.converters.AbstractLoader
- All Implemented Interfaces:
- Loader, java.io.Serializable
- Direct Known Subclasses:
- ArffLoader, C45Loader, CSVLoader, SerializedInstancesLoader
- public abstract class AbstractLoader
- extends java.lang.Object
- implements Loader
Abstract class for Loaders that contains default implementation of the
setSource methods: Any of these methods that are not overwritten will
result in throwing IOException.
- Author:
- Len Trigg
- See Also:
- Serialized Form
Field Summary |
protected static int |
BATCH
For representing that instances have been retrieved in batch mode |
protected static int |
INCREMENTAL
For representing that instances have been retrieved incrementally |
protected int |
m_Retrieval
|
protected static int |
NONE
For state where no instances have been retrieved yet |
Method Summary |
abstract Instances |
getDataSet()
Must be overridden by subclasses. |
abstract Instance |
getNextInstance()
Must be overridden by subclasses. |
protected int |
getRetrieval()
|
abstract Instances |
getStructure()
Must be overridden by subclasses. |
protected void |
setRetrieval(int mode)
|
void |
setSource(java.io.File file)
Resets the Loader object and sets the source of the data set to be
the supplied File object. |
void |
setSource(java.io.InputStream input)
Resets the Loader object and sets the source of the data set to be
the supplied InputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NONE
protected static final int NONE
- For state where no instances have been retrieved yet
BATCH
protected static final int BATCH
- For representing that instances have been retrieved in batch mode
INCREMENTAL
protected static final int INCREMENTAL
- For representing that instances have been retrieved incrementally
m_Retrieval
protected int m_Retrieval
AbstractLoader
public AbstractLoader()
setRetrieval
protected void setRetrieval(int mode)
getRetrieval
protected int getRetrieval()
setSource
public void setSource(java.io.File file)
throws java.io.IOException
- Resets the Loader object and sets the source of the data set to be
the supplied File object.
- Specified by:
setSource
in interface Loader
- Parameters:
file
- the File.- Throws:
java.io.IOException
- always thrown.
setSource
public void setSource(java.io.InputStream input)
throws java.io.IOException
- Resets the Loader object and sets the source of the data set to be
the supplied InputStream.
- Specified by:
setSource
in interface Loader
- Parameters:
input
- the source InputStream.- Throws:
java.io.IOException
- always thrown.
getStructure
public abstract Instances getStructure()
throws java.io.IOException
- Must be overridden by subclasses.
- Specified by:
getStructure
in interface Loader
- Following copied from interface:
weka.core.converters.Loader
- Returns:
- the structure of the data set as an empty set of Instances
- Throws:
java.io.IOException
- if there is no source or parsing fails
public_normal_behavior
requires: model_sourceSupplied == true
&& model_structureDetermined == false
&& (* successful parse *);
modifiable: model_structureDetermined;
ensures: \result != null
&& \result.numInstances() == 0
&& model_structureDetermined == true;
also
public_exceptional_behavior
requires: model_sourceSupplied == false
|| (* unsuccessful parse *);
signals: (IOException);
getDataSet
public abstract Instances getDataSet()
throws java.io.IOException
- Must be overridden by subclasses.
- Specified by:
getDataSet
in interface Loader
- Following copied from interface:
weka.core.converters.Loader
- Returns:
- the full data set as an Instances object
- Throws:
java.io.IOException
- if there is an error during parsing or if
getNextInstance has been called on this source (either incremental
or batch loading can be used, not both).
public_normal_behavior
requires: model_sourceSupplied == true
&& (* successful parse *);
modifiable: model_structureDetermined;
ensures: \result != null
&& \result.numInstances() >= 0
&& model_structureDetermined == true;
also
public_exceptional_behavior
requires: model_sourceSupplied == false
|| (* unsuccessful parse *);
signals: (IOException);
getNextInstance
public abstract Instance getNextInstance()
throws java.io.IOException
- Must be overridden by subclasses.
- Specified by:
getNextInstance
in interface Loader
- Following copied from interface:
weka.core.converters.Loader
- Returns:
- the next instance in the data set as an Instance object or null
if there are no more instances to be read
- Throws:
java.io.IOException
- if there is an error during parsing or if
getDataSet has been called on this source (either incremental
or batch loading can be used, not both).
public_normal_behavior
{|
requires: model_sourceSupplied == true
&& (* successful parse *);
modifiable: model_structureDetermined;
ensures: model_structureDetermined == true
&& \result != null;
also
requires: model_sourceSupplied == true
&& (* no further input *);
modifiable: model_structureDetermined;
ensures: model_structureDetermined == true
&& \result == null;
|}
also
public_exceptional_behavior
{|
requires: model_sourceSupplied == false
|| (* unsuccessful parse *);
signals: (IOException);
also
requires: (* unable to process data set incrementally *);
signals: (IOException);
|}