[29] | 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 | * InstanceEvent.java |
---|
| 19 | * Copyright (C) 2002 University of Waikato, Hamilton, New Zealand |
---|
| 20 | * |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | package weka.gui.beans; |
---|
| 24 | |
---|
| 25 | import weka.core.Instance; |
---|
| 26 | import weka.core.Instances; |
---|
| 27 | |
---|
| 28 | import java.util.EventObject; |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * Event that encapsulates a single instance or header information only |
---|
| 32 | * |
---|
| 33 | * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a> |
---|
| 34 | * @version $Revision: 1.5 $ |
---|
| 35 | * @see EventObject |
---|
| 36 | */ |
---|
| 37 | public class InstanceEvent |
---|
| 38 | extends EventObject { |
---|
| 39 | |
---|
| 40 | /** for serialization */ |
---|
| 41 | private static final long serialVersionUID = 6104920894559423946L; |
---|
| 42 | |
---|
| 43 | public static final int FORMAT_AVAILABLE = 0; |
---|
| 44 | public static final int INSTANCE_AVAILABLE = 1; |
---|
| 45 | public static final int BATCH_FINISHED = 2; |
---|
| 46 | |
---|
| 47 | private Instances m_structure; |
---|
| 48 | private Instance m_instance; |
---|
| 49 | private int m_status; |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * Creates a new <code>InstanceEvent</code> instance that encapsulates |
---|
| 53 | * a single instance only. |
---|
| 54 | * |
---|
| 55 | * @param source the source of the event |
---|
| 56 | * @param instance the instance |
---|
| 57 | * @param status status code (either INSTANCE_AVAILABLE or BATCH_FINISHED) |
---|
| 58 | */ |
---|
| 59 | public InstanceEvent(Object source, Instance instance, int status) { |
---|
| 60 | super(source); |
---|
| 61 | m_instance = instance; |
---|
| 62 | m_status = status; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * Creates a new <code>InstanceEvent</code> instance which encapsulates |
---|
| 67 | * header information only. |
---|
| 68 | * |
---|
| 69 | * @param source an <code>Object</code> value |
---|
| 70 | * @param structure an <code>Instances</code> value |
---|
| 71 | */ |
---|
| 72 | public InstanceEvent(Object source, Instances structure) { |
---|
| 73 | super(source); |
---|
| 74 | m_structure = structure; |
---|
| 75 | m_status = FORMAT_AVAILABLE; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | public InstanceEvent(Object source) { |
---|
| 79 | super(source); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * Get the instance |
---|
| 84 | * |
---|
| 85 | * @return an <code>Instance</code> value |
---|
| 86 | */ |
---|
| 87 | public Instance getInstance() { |
---|
| 88 | return m_instance; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | /** |
---|
| 92 | * Set the instance |
---|
| 93 | * |
---|
| 94 | * @param i an <code>Instance</code> value |
---|
| 95 | */ |
---|
| 96 | public void setInstance(Instance i) { |
---|
| 97 | m_instance = i; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | /** |
---|
| 101 | * Get the status |
---|
| 102 | * |
---|
| 103 | * @return an <code>int</code> value |
---|
| 104 | */ |
---|
| 105 | public int getStatus() { |
---|
| 106 | return m_status; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | /** |
---|
| 110 | * Set the status |
---|
| 111 | * |
---|
| 112 | * @param s an <code>int</code> value |
---|
| 113 | */ |
---|
| 114 | public void setStatus(int s) { |
---|
| 115 | m_status = s; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * Set the instances structure |
---|
| 120 | * |
---|
| 121 | * @param structure an <code>Instances</code> value |
---|
| 122 | */ |
---|
| 123 | public void setStructure(Instances structure) { |
---|
| 124 | m_structure = structure; |
---|
| 125 | m_instance = null; |
---|
| 126 | m_status = FORMAT_AVAILABLE; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | /** |
---|
| 130 | * Get the instances structure (may be null if this is not |
---|
| 131 | * a FORMAT_AVAILABLE event) |
---|
| 132 | * |
---|
| 133 | * @return an <code>Instances</code> value |
---|
| 134 | */ |
---|
| 135 | public Instances getStructure() { |
---|
| 136 | return m_structure; |
---|
| 137 | } |
---|
| 138 | } |
---|