ContextEvent

From MobiComp

Jump to: navigation, search

Summary

ContextEvent is an object used by the ContextService to notify a ContextListener that a ContextElement has been put into, or removed from, the store.

See also:

Developer info

ContextEvent is normally only used when writing a ContextListener.

Java source code is found in the common branch of the src tree in the package org.mobicomp.context. Note that this class is not a subclass of java.util.EventObject as this does not exist in CLDC.

The class has three public attributes:

public Object source; // the object generating the event, usually a ContextService.
public ContextElement element; // the ContextElement put or removed by this event.
public int eventType; // the event type (ContextEvent.PUT (0) or ContextEvent.REMOVE (1))

a constructor, normally only used by the ContextService:

public ContextEvent ( Object src, ContextElement el, int ev )

and three corresponding accessor methods:

public Object getSource()
public ContextElement getElement()
public int getEventType()

notes

Given that we have accessor methods, the three attributes should probably be protected, if not private.

The constructor should also perhaps have more restricted access. nsr 20:48, 10 August 2006 (BST)