FileDocCategorySizeDatePackage
InstrumentedEventListener.javaAPI DocphoneME MR2 API (J2ME)3806Wed May 02 18:00:16 BST 2007com.sun.midp.events

InstrumentedEventListener

public class InstrumentedEventListener extends Object implements EventListener
An implementation of an EventListener that records the events passed to its process() and preprocess() methods.

Fields Summary
boolean
preprocess
The value preprocess() should return.
Vector
processedEvents
Accumulates events passed to process().
Vector
preprocessedEvents
Accumulates events passed to preprocess().
Vector
preprocessedWaitingEvents
Accumulates the waitingEvents passed to preprocess().
Constructors Summary
public InstrumentedEventListener(boolean newPreprocess)
Creates a new InstrumentedEventListener, setting the return value of its preprocess() method to be newPreprocess.

        processedEvents = new Vector();
        preprocessedEvents = new Vector();
        preprocessedWaitingEvents = new Vector();
        preprocess = newPreprocess;
    
public InstrumentedEventListener()
Creates a new InstrumentedEventListener whose preprocess() method returns true.

        this(true);
    
Methods Summary
Event[]getArray(java.util.Vector v)
Returns an array of events, given a vector of events.

        Event eva[] = new Event[v.size()];
        v.copyInto(eva);
        return eva;
    
public Event[]getPreprocessedEvents()
Returns an array of events recorded by the preprocess() method.

        return getArray(preprocessedEvents);
    
public Event[]getProcessedEvents()
Returns an array of events recorded by the process() method.

        return getArray(processedEvents);
    
public Event[]getWaitingEvents()
Returns an array of waiting events recorded by the preprocess() method. Note that there will likely be null elements within this array.

        return getArray(preprocessedWaitingEvents);
    
public booleanpreprocess(Event event, Event waitingEvent)
The preprocess() method of EventListener. Records the event and the waitingEvent in the corresponding vectors. Returns the current value of preprocess.

        preprocessedEvents.addElement(event);
        preprocessedWaitingEvents.addElement(waitingEvent);
        return preprocess;
    
public voidprocess(Event event)
The process() method of EventListener. Simply records the given event in the processedEvents vector.

        processedEvents.addElement(event);
    
public voidsetPreprocess(boolean p)
Sets the return value of the preprocess() method.

        preprocess = p;