edu.berkeley.guir.ptk
Class Events

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.Events
All Implemented Interfaces:
java.io.Serializable

public class Events
extends PTK
implements java.io.Serializable

Convenience class for a collection of Event objects. This class is used in InputSource objects to enable easier creation and dispatch of multiple Event objects. If one Event object is created, the Events object can be treated exactly like a single Event object. If multiple Event objects are created, the you can add them to the Events object as you would a Vector. This class can also be used to perform an action to multiple Event objects with one method call (e.g., addMetadata(MetadataItem) adds the given MetadataItem to all Event objects in this Events object.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
Events()
           
Events(Event e)
          Initializes this object and adds the given Event to it.
Events(Event[] e)
          Initializes this object and adds the given Event objects to it.
Events(java.lang.String id, java.lang.String value)
          Initializes this object, creates a new Event object within this, and adds the ID and data value to it.
 
Method Summary
 void add(Event e)
          Adds the given Event to this.
 void add(Events e)
          Adds all the Event objects in the given Events to this.
 void addData(Data d)
          Adds the given Data to each Event in this Events object.
 void addMetadata(Metadata md)
          Adds the given Metadata to each Event in this Events object.
 void addMetadata(MetadataItem md)
          Adds the given MetadataItem to each Event in this Events object.
 boolean contains(Event e)
          Returns true if the Event e is included in this.
 boolean contains(Events e)
          Returns true if the Event objects at index 0 in e is included in this.
 boolean containsAll(Events e)
          Returns true if all the Event objects in e are included in this.
 boolean equals(Events e)
          Returns true if all the Event objects in e are contained in this.
 Event get(int i)
          Get the Event at index i in this.
 java.util.Vector getAll()
          Get all the Event objects in this.
 Event[] getAsArray()
          Get all the Event objects in this as an array.
 boolean isEmpty()
          Returns true if this has no Event objects.
 void set(int i, Event e)
           
 int size()
          Returns an integer indicating how many Event objects are included in this.
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Events

public Events()

Events

public Events(java.lang.String id,
              java.lang.String value)
Initializes this object, creates a new Event object within this, and adds the ID and data value to it.

Parameters:
id - data ID
value - data value

Events

public Events(Event e)
Initializes this object and adds the given Event to it.

Parameters:
e - Event to add to this.

Events

public Events(Event[] e)
Initializes this object and adds the given Event objects to it.

Parameters:
e - an array of Event objects to add to this.
Method Detail

equals

public boolean equals(Events e)
Returns true if all the Event objects in e are contained in this.

Parameters:
e - Events object to check for equivalence to this.
Returns:
boolean indicating whether or not the two include the same Event objects.

addData

public void addData(Data d)
Adds the given Data to each Event in this Events object. If no events are present, this method creates an Event with the default constructor, adds the Data to it, and adds it to the Events object.

Parameters:
d -

addMetadata

public void addMetadata(MetadataItem md)
Adds the given MetadataItem to each Event in this Events object. If no events are present, this method creates an Event with the default constructor, adds the metadata to it, and adds it to the Events object.


addMetadata

public void addMetadata(Metadata md)
Adds the given Metadata to each Event in this Events object. If no events are present, this method creates an Event with the default constructor, adds the metadata to it, and adds it to the Events object.


add

public void add(Event e)
Adds the given Event to this.

Parameters:
e - Event to add.

add

public void add(Events e)
Adds all the Event objects in the given Events to this.

Parameters:
e - Events to add.

set

public void set(int i,
                Event e)

isEmpty

public boolean isEmpty()
Returns true if this has no Event objects.

Returns:
true if empty.

size

public int size()
Returns an integer indicating how many Event objects are included in this.

Returns:
the number of Event objects in this.

contains

public boolean contains(Events e)
Returns true if the Event objects at index 0 in e is included in this. Uses Event.equals to determine equality of Event objects. Requires that the given Events parameter is of size 1 (only 1 Event object). Use containsAll() for multiple Events objects.

Parameters:
e - Events of size 1 to check for in this Events.
Returns:
true if the Event objects in e is contained in this.

contains

public boolean contains(Event e)
Returns true if the Event e is included in this.

Parameters:
e - Event to check for in this Events.
Returns:
true if the Event e is contained in this.

containsAll

public boolean containsAll(Events e)
Returns true if all the Event objects in e are included in this. Uses Event.equals to determine equality of Event objects.

Parameters:
e - Events to check for in this Events.
Returns:
true if all the Event objects in e are contained in this.

get

public Event get(int i)
Get the Event at index i in this.

Parameters:
i - index of Event to get.
Returns:
the Event at index i.

getAll

public java.util.Vector getAll()
Get all the Event objects in this.

Returns:
a Vector of all the Event objects.

getAsArray

public Event[] getAsArray()
Get all the Event objects in this as an array.

Returns:
Event[]