weka.gui.streams
Class InstanceJoiner

java.lang.Object
  extended byweka.gui.streams.InstanceJoiner
All Implemented Interfaces:
java.util.EventListener, InstanceProducer, SerialInstanceListener, java.io.Serializable

public class InstanceJoiner
extends java.lang.Object
implements java.io.Serializable, InstanceProducer, SerialInstanceListener

A bean that joins two streams of instances into one.

Version:
$Revision: 1.3 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  boolean b_Debug
          Debugging mode
private  boolean b_FirstInputFinished
          Whether the first input batch has finished
private  boolean b_SecondInputFinished
           
private  java.util.Vector listeners
          The listeners
protected  Instances m_InputFormat
          The input format for instances
private  Instance m_OutputInstance
          The current output instance
 
Constructor Summary
InstanceJoiner()
          Setup the initial states of the member variables
 
Method Summary
 void addInstanceListener(InstanceListener ipl)
           
 void batchFinished()
          Signify that this batch of input to the filter is finished.
 boolean getDebug()
           
 boolean input(Instance instance)
           
 boolean inputFormat(Instances instanceInfo)
          Sets the format of the input instances.
 void instanceProduced(InstanceEvent e)
           
protected  void notifyInstanceProduced(InstanceEvent e)
           
 Instances outputFormat()
          Gets the format of the output instances.
 Instance outputPeek()
          Output an instance after filtering but do not remove from the output queue.
 void removeInstanceListener(InstanceListener ipl)
           
 void secondInstanceProduced(InstanceEvent e)
           
 void setDebug(boolean debug)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

private java.util.Vector listeners
The listeners


b_Debug

private boolean b_Debug
Debugging mode


m_InputFormat

protected Instances m_InputFormat
The input format for instances


m_OutputInstance

private Instance m_OutputInstance
The current output instance


b_FirstInputFinished

private boolean b_FirstInputFinished
Whether the first input batch has finished


b_SecondInputFinished

private boolean b_SecondInputFinished
Constructor Detail

InstanceJoiner

public InstanceJoiner()
Setup the initial states of the member variables

Method Detail

inputFormat

public boolean inputFormat(Instances instanceInfo)
Sets the format of the input instances. If the filter is able to determine the output format before seeing any input instances, it does so here. This default implementation assumes the output format is determined when batchFinished() is called.

Parameters:
instanceInfo - an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).
Returns:
true if the outputFormat may be collected immediately

outputFormat

public Instances outputFormat()
                       throws java.lang.Exception
Gets the format of the output instances. This should only be called after input() or batchFinished() has returned true.

Specified by:
outputFormat in interface InstanceProducer
Returns:
an Instances object containing the output instance structure only.
Throws:
java.lang.Exception - if no input structure has been defined (or the output format hasn't been determined yet)

input

public boolean input(Instance instance)
              throws java.lang.Exception
Throws:
java.lang.Exception

batchFinished

public void batchFinished()
                   throws java.lang.Exception
Signify that this batch of input to the filter is finished. If the filter requires all instances prior to filtering, output() may now be called to retrieve the filtered instances. Any subsequent instances filtered should be filtered based on setting obtained from the first batch (unless the inputFormat has been re-assigned or new options have been set). This default implementation assumes all instance processing occurs during inputFormat() and input().

Returns:
true if there are instances pending output
Throws:
java.lang.Exception - if no input structure has been defined

outputPeek

public Instance outputPeek()
                    throws java.lang.Exception
Output an instance after filtering but do not remove from the output queue.

Specified by:
outputPeek in interface InstanceProducer
Returns:
the instance that has most recently been filtered (or null if the queue is empty).
Throws:
java.lang.Exception - if no input structure has been defined

setDebug

public void setDebug(boolean debug)

getDebug

public boolean getDebug()

addInstanceListener

public void addInstanceListener(InstanceListener ipl)
Specified by:
addInstanceListener in interface InstanceProducer

removeInstanceListener

public void removeInstanceListener(InstanceListener ipl)
Specified by:
removeInstanceListener in interface InstanceProducer

notifyInstanceProduced

protected void notifyInstanceProduced(InstanceEvent e)

instanceProduced

public void instanceProduced(InstanceEvent e)

secondInstanceProduced

public void secondInstanceProduced(InstanceEvent e)
Specified by:
secondInstanceProduced in interface SerialInstanceListener