AbstractLoader.java
Upload User: rhdiban
Upload Date: 2013-08-09
Package Size: 15085k
Code Size: 3k
Category:

Windows Develop

Development Platform:

Java

  1. /*
  2.  *    This program is free software; you can redistribute it and/or modify
  3.  *    it under the terms of the GNU General Public License as published by
  4.  *    the Free Software Foundation; either version 2 of the License, or
  5.  *    (at your option) any later version.
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  *    GNU General Public License for more details.
  11.  *
  12.  *    You should have received a copy of the GNU General Public License
  13.  *    along with this program; if not, write to the Free Software
  14.  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  */
  16. /*
  17.  *    Loader.java
  18.  *    Copyright (C) 2000 Webmind Corp.
  19.  *
  20.  */
  21. package weka.core.converters;
  22. import java.io.File;
  23. import java.io.InputStream;
  24. import java.io.IOException;
  25. import java.io.Serializable;
  26. import weka.core.Instances;
  27. import weka.core.Instance;
  28. /**
  29.  * Abstract class for Loaders that contains default implementation of the
  30.  * setSource methods: Any of these methods that are not overwritten will
  31.  * result in throwing IOException.
  32.  *
  33.  * @author <a href="mailto:len@webmind.com">Len Trigg</a>
  34.  * @version $Revision: 1.3 $
  35.  */
  36. public abstract class AbstractLoader implements Loader {
  37.   /** For state where no instances have been retrieved yet */
  38.   protected static final int NONE = 0;
  39.   /** For representing that instances have been retrieved in batch mode */
  40.   protected static final int BATCH = 1;
  41.   /** For representing that instances have been retrieved incrementally */
  42.   protected static final int INCREMENTAL = 2;
  43.   protected int m_Retrieval = NONE;
  44.   protected void setRetrieval(int mode) { m_Retrieval = mode; }
  45.   protected int getRetrieval() { return m_Retrieval; }
  46.   /**
  47.    * Resets the Loader object and sets the source of the data set to be 
  48.    * the supplied File object.
  49.    *
  50.    * @param file the File.
  51.    * @exception IOException always thrown.
  52.    */
  53.   public void setSource(File file) throws IOException {
  54.     throw new IOException("operation not supported");
  55.   }
  56.   /**
  57.    * Resets the Loader object and sets the source of the data set to be 
  58.    * the supplied InputStream.
  59.    *
  60.    * @param input the source InputStream.
  61.    * @exception IOException always thrown.
  62.    */
  63.   public void setSource(InputStream input) throws IOException {
  64.     throw new IOException("operation not supported");
  65.   }
  66.   /**
  67.    * Must be overridden by subclasses.
  68.    */
  69.   public abstract Instances getStructure() throws IOException;
  70.   /**
  71.    * Must be overridden by subclasses.
  72.    */
  73.   public abstract Instances getDataSet() throws IOException;
  74.   /**
  75.    * Must be overridden by subclasses.
  76.    */
  77.   public abstract Instance getNextInstance() throws IOException;
  78. }