edu.berkeley.guir.ptk
Class Event

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

public class Event
extends PTK
implements java.io.Serializable

Contains the data that an input source sends to applications and the metadata identifying this data. Includes several other pieces of information useful to identifying, classifying, or describing an event: the notification level, a timestamp indicating when the event was created, a display step number indicating the order in which events are displayed if a set is displayed together, a boolean indicating whether or not the event is meant to wait for some user action (e.g., in the case of a demand action notifiation level), and a DisplayInfo object that includes application-specific information on how to display the event (the default DisplayInfo object is only instantiated if the event is passed to a Transition object and it includes color, location, and animation fields; you can install a custom DisplayInfo object by passing it to a Transition, which would be passed into your Output's constructor).

Author:
tmatthew Created: Feb 18, 2003
See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable data
          Hashtable of data items.
 DisplayInfo display_info
          Includes application-specific information on how to display the event (the default DisplayInfo object is only instantiated if the event is passed to a Transition object and it includes only a color field; you can install a custom DisplayInfo object when you initialize your Transition).
protected  int display_step_num
          In the case that a number of events are displayed together, indicates the order in which the events should be displayed.
protected  boolean grab_action_event
          This boolean member data just stores whether or not this event should trigger a call to the checkTheAction() method in output.
protected static int HASH_SIZE
          The number of data items possible (until re-hash).
protected  java.util.Hashtable metadata
          Hashtable of metadata item.
 int notification
          Notification level for this vent.
protected  java.util.Date timestamp
          Time the event was created.
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
Event()
           
 
Method Summary
 void addData(Data d)
          Adds a Data to the Event.
 void addData(Event from)
          Adds copies of the data items from one event (from) to this event.
 void addMetadata(Event from)
          Add copies of the metadata items from the given event (from) to this event while leaving this event's metadata in tact.
 void addMetadata(Metadata m)
          Adds all MetadataItem objects in Metadata to the Event.
 void addMetadata(MetadataItem md)
          Adds a MetadataItem to the Event.
 boolean areAnyMetadataIncluded(Metadata[] md)
          Takes an array of Metadata objects and returns true if any of the Metadata objects is included in this event's metadata.
 boolean areMetadataIDsIncluded(java.lang.String[] ids)
          Checks if a series of ids are metadata ids for this Event's metadata.
 Event copy()
          Returns a copy of this Event in new memory.
 int dataSize()
          Rreturns the number of Data in the Event.
 DisplayInfo displayInfoCopy()
          Returns a copy of the DisplayInfo installed in this Event if the Event has been passed through a Transition.
 boolean doesDataMatch(Data[] d)
          Check if this Event's data exactly match the given Data (id, value pairs).
 boolean doesMetadataMatch(Metadata md)
          Check if this Event's metadata exactly match the given Metadata (id, value pairs).
 boolean doesMetadataMatch(MetadataItem[] md)
          Check if this Event's metadata exactly match the given MetadataItems (id, value pairs).
 boolean doMetadataIDsMatch(java.lang.String[] ids)
          Checks if a series of ids are the same ids as this the ids in this Event's metadata.
(package private)  boolean equals(Event e)
          Returns true if the given Event has the same metadata, data, notification level, and timestamp.
 Data[] getAllData()
          Returns an array of all the Data in the Event.
 Metadata getAllMetadata()
          Returns a Metadata object, which contains all the MetadataItems in the Event.
 MetadataItem[] getAllMetadataAsArray()
          Returns an array of all the MetadataItems in the Event.
 int getAnimation()
          Returns the animation of this Event if it has a DisplayInfo installed.
 int getColor()
          Returns the color of this Event if it has a DisplayInfo installed.
 Data getData(java.lang.String id)
          Takes an id and returns the Data object associated with the id.
 int getDisplayStepNum()
          In the case that a number of events are displayed together, returns a number that indicates the order in which the events should be displayed.
 java.awt.Point getLocation()
          Returns the location of this Event if it has a DisplayInfo installed.
 MetadataItem getMetadata(java.lang.String id)
          Takes an id and returns the MetadataItem object associated with the id.
 java.lang.String getMetadataValue(java.lang.String id)
          Takes an id and returns the value of the MetadataItem object associated with the id.
 int getNotificationLevel()
          Returns the notification level of this Event.
 java.util.Date getTimeCreated()
          Returns the time this Event was created as a Date.
 boolean isDataIncluded(java.lang.String id)
          Check if this Event's data includes data for the given id.
 boolean isDataIncluded(java.lang.String[] ids)
          Data Check if this Event's data includes data the given ids.
 boolean isGrabAction()
          Returns true if this Event is meant to cause a user to do some action; used with "demand action" notification levels only.
 boolean isIgnoreEvent()
           
 boolean isMetadataIncluded(Metadata md)
          Check if this Event's metadata includes the given Metadata (id, value pairs).
 boolean isMetadataIncluded(MetadataItem md)
          Check if this Event's metadata includes the given MetadataItem (id, value pair).
 boolean isMetadataIncluded(MetadataItem[] md)
          Check if this Event's metadata includes the given MetadataItems (id, value pairs).
 int metadataSize()
          The number of MetadataItems in the Event.
 void removeAllData()
          Removes all the data items from this event.
 void removeAllMetadata()
          Removes all the metadata items from this event.
 void removeData(java.lang.String id)
          Removes the Data from the Event with the given id.
 void removeMetadata(java.lang.String id)
          Removes the MetadataItem from the Event with the given id.
 void replaceData(Event from)
          Removes this event's data and then copies the data items from the given event (from) to this event.
 void replaceMetadata(Event from)
          Removes this event's metadata and then copies the metadata items from the given event (from) to this event.
 void setAnimation(int a)
          Sets the animation of this Event if it has a DisplayInfo installed.
 void setColor(int c)
          Sets the color of this Event if it has a DisplayInfo installed.
 void setDisplayStepNum(int n)
          This method should only be called if multiple events are displayed together (e.g., in a Transition).
 void setGrabAction(boolean g)
          Sets a boolean indicating whether or not this Event is meant to cause a user to do some action; used with "demand action" notification levels only.
 void setLocation(java.awt.Point p)
          Sets the location of this Event if it has a DisplayInfo installed.
 void setNotificationLevel(int n)
          Sets the notification level of this Event.
 void setTimeCreated(java.util.Date d)
          Sets the time this Event was created as a Calendar.
 void updateData(java.lang.String id, Data d)
          Updates an existing Data with the given value.
 void updateMetadataValue(java.lang.String id, java.lang.String value)
          Updates an existing MetadataItem with the given value.
 
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
 

Field Detail

notification

public int notification
Notification level for this vent. Initialized to -1 (PTKConstants.NOTIFICATION_LEVEL_NOT_SET).


timestamp

protected java.util.Date timestamp
Time the event was created.


display_step_num

protected int display_step_num
In the case that a number of events are displayed together, indicates the order in which the events should be displayed. Step numbers start with 0.


display_info

public DisplayInfo display_info
Includes application-specific information on how to display the event (the default DisplayInfo object is only instantiated if the event is passed to a Transition object and it includes only a color field; you can install a custom DisplayInfo object when you initialize your Transition).


grab_action_event

protected boolean grab_action_event
This boolean member data just stores whether or not this event should trigger a call to the checkTheAction() method in output. This member data should be set during a transition call.


HASH_SIZE

protected static final int HASH_SIZE
The number of data items possible (until re-hash). Set to 20.

See Also:
Constant Field Values

metadata

protected java.util.Hashtable metadata
Hashtable of metadata item. Hashes MetadataItem objects by MetadataItem.id (the ID is the key to the hashtable).


data

protected java.util.Hashtable data
Hashtable of data items. Hashes Data objects by Data.id

Constructor Detail

Event

public Event()
Method Detail

getTimeCreated

public java.util.Date getTimeCreated()
Returns the time this Event was created as a Date.

Returns:
Date

setTimeCreated

public void setTimeCreated(java.util.Date d)
Sets the time this Event was created as a Calendar.


getDisplayStepNum

public int getDisplayStepNum()
In the case that a number of events are displayed together, returns a number that indicates the order in which the events should be displayed. Step numbers start with 0.

Returns:
int

setDisplayStepNum

public void setDisplayStepNum(int n)
This method should only be called if multiple events are displayed together (e.g., in a Transition). The default step number is 0.

Parameters:
n -

getColor

public int getColor()
Returns the color of this Event if it has a DisplayInfo installed. Color is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.

Returns:
int the integer value of a color.

setColor

public void setColor(int c)
Sets the color of this Event if it has a DisplayInfo installed. Color is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.

Parameters:
c - the integer value of a color.

getLocation

public java.awt.Point getLocation()
Returns the location of this Event if it has a DisplayInfo installed. Color is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.

Returns:
int the integer value of a color.

setLocation

public void setLocation(java.awt.Point p)
Sets the location of this Event if it has a DisplayInfo installed. Location is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.


getAnimation

public int getAnimation()
Returns the animation of this Event if it has a DisplayInfo installed. Animation is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.

Returns:
int the integer value of animation.

setAnimation

public void setAnimation(int a)
Sets the animation of this Event if it has a DisplayInfo installed. Animation is an attribute of DisplayInfo and will not be set if the Event has no DisplayInfo. DisplayInfo is instantiated in Transition, and not all Outputs use Transitions.

Parameters:
a - the integer value of animation.

isGrabAction

public boolean isGrabAction()
Returns true if this Event is meant to cause a user to do some action; used with "demand action" notification levels only.

Returns:
boolean

setGrabAction

public void setGrabAction(boolean g)
Sets a boolean indicating whether or not this Event is meant to cause a user to do some action; used with "demand action" notification levels only.

Returns:
boolean

getNotificationLevel

public int getNotificationLevel()
Returns the notification level of this Event. This gives an indication of the importance of the data contained in this Event.

Returns:
int

setNotificationLevel

public void setNotificationLevel(int n)
Sets the notification level of this Event. This method is used by NotificationSetters

Parameters:
n - the notification level.

isIgnoreEvent

public boolean isIgnoreEvent()

equals

boolean equals(Event e)
Returns true if the given Event has the same metadata, data, notification level, and timestamp.

Parameters:
e -
Returns:
boolean

copy

public Event copy()
Returns a copy of this Event in new memory.

Returns:
a copy of this Event

displayInfoCopy

public DisplayInfo displayInfoCopy()
Returns a copy of the DisplayInfo installed in this Event if the Event has been passed through a Transition. Returns null if no DisplayInfo is installed.


removeAllData

public void removeAllData()
Removes all the data items from this event. The rest of the Event is left as is.


removeAllMetadata

public void removeAllMetadata()
Removes all the metadata items from this event. The rest of the Event is left as is.


addMetadata

public void addMetadata(Event from)
Add copies of the metadata items from the given event (from) to this event while leaving this event's metadata in tact.

Parameters:
from - the Event to copy metadata from.

replaceMetadata

public void replaceMetadata(Event from)
Removes this event's metadata and then copies the metadata items from the given event (from) to this event.

Parameters:
from - the Event to copy metadata from.

addData

public void addData(Event from)
Adds copies of the data items from one event (from) to this event.

Parameters:
from -

replaceData

public void replaceData(Event from)
Removes this event's data and then copies the data items from the given event (from) to this event.

Parameters:
from -

addData

public void addData(Data d)
Adds a Data to the Event. If the Data already exists in the Event, this method will update the existing Data.

Parameters:
d - The Data to add.

updateData

public void updateData(java.lang.String id,
                       Data d)
Updates an existing Data with the given value.

Parameters:
id - The id of the Data to update.

removeData

public void removeData(java.lang.String id)
Removes the Data from the Event with the given id.

Parameters:
id - Indicates which Data to remove.

getAllData

public Data[] getAllData()
Returns an array of all the Data in the Event.

Returns:
Data[] An array of all the Data in the Event.

getData

public Data getData(java.lang.String id)
Takes an id and returns the Data object associated with the id. Data ids must be unique within a single template.

Parameters:
id - The id of the Data to get.
Returns:
Data The Data object associated with the given id. Returns null if Data with the specified id is not in the.

doesDataMatch

public boolean doesDataMatch(Data[] d)
Check if this Event's data exactly match the given Data (id, value pairs).

Parameters:
d -
Returns:
boolean True if the given data matches the Event's data.

isDataIncluded

public boolean isDataIncluded(java.lang.String[] ids)
Data Check if this Event's data includes data the given ids. Return true if data is included.

Parameters:
ids - Array of data ids Strings.

isDataIncluded

public boolean isDataIncluded(java.lang.String id)
Check if this Event's data includes data for the given id. Return true if data is included.

Parameters:
id - Data id String.

dataSize

public int dataSize()
Rreturns the number of Data in the Event.

Returns:
int

addMetadata

public void addMetadata(MetadataItem md)
Adds a MetadataItem to the Event.

Parameters:
md - The MetadataItem to add.

addMetadata

public void addMetadata(Metadata m)
Adds all MetadataItem objects in Metadata to the Event.


updateMetadataValue

public void updateMetadataValue(java.lang.String id,
                                java.lang.String value)
Updates an existing MetadataItem with the given value.

Parameters:
id - The id of the MetadataItem to update.
value - The new value of the MetadataItem.

removeMetadata

public void removeMetadata(java.lang.String id)
Removes the MetadataItem from the Event with the given id.

Parameters:
id - Indicates which MetadataItem to remove.

getAllMetadata

public Metadata getAllMetadata()
Returns a Metadata object, which contains all the MetadataItems in the Event.

Returns:
Metadata a Metadata object representing all the MetadataItems in the Event.

getAllMetadataAsArray

public MetadataItem[] getAllMetadataAsArray()
Returns an array of all the MetadataItems in the Event.

Returns:
Metadata a Metadata object representing all the MetadataItems in the Event.

getMetadata

public MetadataItem getMetadata(java.lang.String id)
Takes an id and returns the MetadataItem object associated with the id. Data ids must be unique within a single template.

Parameters:
id -
Returns:
MetadataItem The MetadataItem object associated with the id. Null if MetadataItem with the specified id is not in the Event.

getMetadataValue

public java.lang.String getMetadataValue(java.lang.String id)
Takes an id and returns the value of the MetadataItem object associated with the id. Data ids must be unique within a single template.

Parameters:
id -
Returns:
String The value of the MetadataItem object associated with the given id. Null if MetadataItem with the specified id is not in the Event.

doesMetadataMatch

public boolean doesMetadataMatch(MetadataItem[] md)
Check if this Event's metadata exactly match the given MetadataItems (id, value pairs).

Parameters:
md -
Returns:
boolean True if metadata match.

doesMetadataMatch

public boolean doesMetadataMatch(Metadata md)
Check if this Event's metadata exactly match the given Metadata (id, value pairs).

Parameters:
md -
Returns:
boolean True if metadata match.

isMetadataIncluded

public boolean isMetadataIncluded(MetadataItem[] md)
Check if this Event's metadata includes the given MetadataItems (id, value pairs).

Parameters:
md -
Returns:
boolean True if metadata is included.

isMetadataIncluded

public boolean isMetadataIncluded(Metadata md)
Check if this Event's metadata includes the given Metadata (id, value pairs).

Parameters:
md -
Returns:
boolean True if metadata is included.

areAnyMetadataIncluded

public boolean areAnyMetadataIncluded(Metadata[] md)
Takes an array of Metadata objects and returns true if any of the Metadata objects is included in this event's metadata.

Parameters:
md -
Returns:

isMetadataIncluded

public boolean isMetadataIncluded(MetadataItem md)
Check if this Event's metadata includes the given MetadataItem (id, value pair).

Parameters:
md -
Returns:
boolean True if metadata is included.

doMetadataIDsMatch

public boolean doMetadataIDsMatch(java.lang.String[] ids)
Checks if a series of ids are the same ids as this the ids in this Event's metadata. Doesn't worry about the metadata values. Must have the exact same set of ids (no extra ids in either).

Parameters:
ids -
Returns:
boolean True if the metadata ids in the Event exactly match the given array of id strings.

areMetadataIDsIncluded

public boolean areMetadataIDsIncluded(java.lang.String[] ids)
Checks if a series of ids are metadata ids for this Event's metadata. Just checks for inclusion - other metadata ids can be in the Event. Doesn't worry about the metadata values.

Parameters:
ids -
Returns:
boolean Returns true if all the given ids are ids for metadata that are included in the Event.

metadataSize

public int metadataSize()
The number of MetadataItems in the Event.

Returns:
int The number of MetadataItems in the Event.