source: branches/MetisMQI/src/main/java/weka/core/converters/AbstractLoader.java

Last change on this file was 29, checked in by gnappo, 15 years ago

Taggata versione per la demo e aggiunto branch.

File size: 2.7 KB
Line 
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/*
18 *    AbstractLoader.java
19 *    Copyright (C) 2002 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.core.converters;
24
25import weka.core.Instances;
26import weka.core.Instance;
27import java.io.*;
28
29/**
30 * Abstract class gives default implementation of setSource
31 * methods. All other methods must be overridden.
32 *
33 * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
34 * @version $Revision: 5953 $
35 */
36public abstract class AbstractLoader implements Loader {
37 
38  /** The retrieval modes */
39  protected static final int NONE = 0;
40  protected static final int BATCH = 1;
41  protected static final int INCREMENTAL = 2;
42
43  /** The current retrieval mode */
44  protected int m_retrieval;
45
46  /**
47   * Sets the retrieval mode.
48   *
49   * @param mode the retrieval mode
50   */
51  protected void setRetrieval(int mode) {
52
53    m_retrieval = mode;
54  }
55
56  /**
57   * Gets the retrieval mode.
58   *
59   * @return the retrieval mode
60   */
61  protected int getRetrieval() {
62
63    return m_retrieval;
64  }
65
66  /**
67   * Default implementation throws an IOException.
68   *
69   * @param file the File
70   * @exception IOException always
71   */
72  public void setSource(File file) throws IOException {
73
74    throw new IOException("Setting File as source not supported");
75  }
76
77  /**
78   * Default implementation sets retrieval mode to NONE
79   *
80   * @exception never.
81   */
82  public void reset() throws Exception {
83    m_retrieval = NONE;
84  }
85 
86  /**
87   * Default implementation throws an IOException.
88   *
89   * @param input the input stream
90   * @exception IOException always
91   */
92  public void setSource(InputStream input) throws IOException {
93
94    throw new IOException("Setting InputStream as source not supported");
95  }
96 
97  /*
98   * To be overridden.
99   */
100  public abstract Instances getStructure() throws IOException;
101
102  /*
103   * To be overridden.
104   */
105  public abstract Instances getDataSet() throws IOException;
106
107  /*
108   * To be overridden.
109   */
110  public abstract Instance getNextInstance(Instances structure) throws IOException;
111}
Note: See TracBrowser for help on using the repository browser.