|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--context.arch.BaseObject | +--context.arch.widget.Widget
This class is the basic context widget, with attributes and methods that should apply to all context widgets.
BaseObject
Field Summary | |
protected Attributes |
attributes
|
protected java.util.Hashtable |
attributeTypes
|
protected Callbacks |
callbacks
|
static java.lang.String |
CLASS
Tag for the class file being used by the widget |
protected long |
CurrentOffset
|
static int |
DEFAULT_PORT
Default port for widgets to use |
protected java.lang.String |
id
|
static java.lang.String |
PUT_DATA
Tag to indicate the widget should accept the given data |
static java.lang.String |
PUT_DATA_REPLY
Tag to indicate the reply to a PUT_DATA message |
static java.lang.String |
QUERY
Tag to indicate the widget should return the latest stored data |
static java.lang.String |
QUERY_ATTRIBUTES
Tag to indicate the widget should return its list of attributes |
static java.lang.String |
QUERY_ATTRIBUTES_REPLY
Tag to indicate the reply to a QUERY_ATTRIBUTES message |
static java.lang.String |
QUERY_CALLBACKS
Tag to indicate the widget should return its list of callbacks |
static java.lang.String |
QUERY_CALLBACKS_REPLY
Tag to indicate the reply to a QUERY_CALLBACKS message |
static java.lang.String |
QUERY_REPLY
Tag to indicate the reply to a QUERY message |
static java.lang.String |
QUERY_SERVICES
Tag to indicate the widget should return its list of services |
static java.lang.String |
QUERY_SERVICES_REPLY
Tag to indicate the reply to a QUERY_SERVICES message |
static java.lang.String |
QUERY_VERSION
Tag to indicate the widget should return its version number |
static java.lang.String |
QUERY_VERSION_REPLY
Tag to indicate the reply to a QUERY_VERSION message |
protected Services |
services
|
static java.lang.String |
SPACER
Constant for the widget spacer |
StorageObject |
storage
Object to keep track of storage |
Subscribers |
subscribers
Object to handle subscriptions to context data |
static java.lang.String |
TIMESTAMP
Tag for the timestamp of widget data |
static java.lang.String |
UPDATE
Tag to indicate an update is being sent |
static java.lang.String |
UPDATE_AND_QUERY
Tag to indicate the widget should get the latest data from the generator and return them |
static java.lang.String |
UPDATE_AND_QUERY_REPLY
Tag to indicate the reply to an UPDATE_AND_QUERY message |
static java.lang.String |
VERSION
Tag for version number. |
java.lang.String |
VERSION_NUMBER
Dummy version number. |
Fields inherited from class context.arch.BaseObject |
communications,
EXIT_OK,
handlers,
ID,
parser,
PING,
PING_REPLY,
serviceHandlers |
Constructor Summary | |
Widget(int port,
java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. |
|
Widget(int port,
java.lang.String id,
boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. |
|
Widget(java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. |
|
Widget(java.lang.String id,
boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. |
|
Widget(java.lang.String clientClass,
java.lang.String serverClass,
int serverPort,
java.lang.String encoderClass,
java.lang.String decoderClass,
boolean storageFlag,
java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info. |
|
Widget(java.lang.String clientClass,
java.lang.String serverClass,
int serverPort,
java.lang.String encoderClass,
java.lang.String decoderClass,
java.lang.String storageClass,
java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info. |
Method Summary | |
protected DataObject |
addSubscriber(DataObject sub,
java.lang.String error)
This method adds a subscriber to this object. |
protected boolean |
canHandle(AttributeFunctions atts,
Conditions conds)
This method checks the list of attributes and conditions to ensure that the widget contains these attributes. |
protected boolean |
canHandle(AttributeNameValues atts)
This method checks the list of attributes (in an AttributeNameValues object) to ensure that the widget contains these attributes. |
protected boolean |
canHandle(Attributes attributes)
This method checks the list of attributes to ensure that the widget contains these attributes. |
protected boolean |
canHandle(Attributes atts,
Conditions conds)
This method checks the list of attributes and conditions to ensure that the widget contains these attributes. |
protected DataObject |
executeService(DataObject request,
java.lang.String error)
This method attempts to execute a widget service. |
protected java.lang.String |
getAttributeType(java.lang.String name)
Returns the attribute value with the given name |
protected java.lang.Long |
getCurrentTime()
This method returns the current time to use as a timestamp |
protected void |
getNewOffset()
This method creates a thread that retrieves a global time clock and determines the offset between the local clock and the global clock. |
protected long |
getNewOffsetNoDelay()
This method retrieves the offset between the local clock and a global clock with no delay. |
protected boolean |
isAttribute(java.lang.String name)
Checks if the given attribute is an attribute of this widget |
protected boolean |
isCallback(java.lang.String name)
Checks if the given callback is an callback of this widget |
void |
notify(java.lang.String event,
java.lang.Object data)
This is an empty method that should be overridden by objects that subclass from this class. |
protected void |
processCallbackReply(DataObject result,
Subscriber sub)
This method should be overriden to process the results of subscription callbacks. |
protected DataObject |
putData(DataObject data,
java.lang.String error)
This method puts context data in a widget. |
protected DataObject |
queryAttributes(DataObject query,
java.lang.String error)
This method queries the attributes of a widget. |
protected DataObject |
queryCallbacks(DataObject query,
java.lang.String error)
This method queries the callbacks of a widget. |
protected abstract AttributeNameValues |
queryGenerator()
This abstract method is called when the widget wants to get the latest generator info. |
protected DataObject |
queryServices(DataObject query,
java.lang.String error)
This method queries the services of a widget. |
protected DataObject |
queryWidget(DataObject query,
boolean update,
java.lang.String error)
This method runs a query on a widget, asking for either it's latest acquired data (QUERY) or asking for the widget to acquire and return new data (UPDATE_AND_QUERY) |
protected DataObject |
removeSubscriber(DataObject sub,
java.lang.String error)
This method removes a subscriber to this object. |
protected DataObject |
retrieveData(DataObject data,
java.lang.String error)
This method retrieves data from the widget's storage. |
DataObject |
runUserMethod(DataObject data)
This method is meant to handle any internal methods that the baseObject doesn't handle. |
protected DataObject |
runWidgetMethod(DataObject data,
java.lang.String error)
This is an empty method that should be overridden by objects that subclass from this class. |
protected void |
sendToSubscribers(java.lang.String callback,
AttributeNameValues atts)
This method should be called to send data to subscribers when a context widget's callback is triggered. |
protected void |
setAttribute(java.lang.String name,
java.lang.String type)
Sets an attribute |
protected abstract Attributes |
setAttributes()
Sets the attributes for the widget |
protected abstract Callbacks |
setCallbacks()
Sets the callbacks for the widget |
protected abstract Services |
setServices()
Sets the services for the widget |
protected void |
store(AttributeNameValues data)
This stub method stores the data in the given AttributeNameValues object |
protected void |
store(DataObject data)
This stub method stores the data in the given DataObject |
protected void |
updateWidgetInformation()
This method is called when a remote component sends an UPDATE_AND_QUERY message. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String CLASS
public java.lang.String VERSION_NUMBER
public static final int DEFAULT_PORT
public static final java.lang.String VERSION
public static final java.lang.String TIMESTAMP
public static final java.lang.String QUERY
public static final java.lang.String QUERY_REPLY
public static final java.lang.String UPDATE_AND_QUERY
public static final java.lang.String UPDATE_AND_QUERY_REPLY
public static final java.lang.String QUERY_ATTRIBUTES
public static final java.lang.String QUERY_ATTRIBUTES_REPLY
public static final java.lang.String QUERY_CALLBACKS
public static final java.lang.String QUERY_CALLBACKS_REPLY
public static final java.lang.String QUERY_SERVICES
public static final java.lang.String QUERY_SERVICES_REPLY
public static final java.lang.String QUERY_VERSION
public static final java.lang.String QUERY_VERSION_REPLY
public static final java.lang.String PUT_DATA
public static final java.lang.String PUT_DATA_REPLY
public static final java.lang.String UPDATE
public static final java.lang.String SPACER
protected java.lang.String id
protected Attributes attributes
protected java.util.Hashtable attributeTypes
protected Callbacks callbacks
protected Services services
protected long CurrentOffset
public Subscribers subscribers
Subscribers
,
Subscriber
public StorageObject storage
StorageObject
Constructor Detail |
public Widget(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, java.lang.String storageClass, java.lang.String id)
clientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port to use for server communicationsencoderClass
- Class to use for communications encodingdecoderClass
- Class to use for communications decodingstorageClass
- Class to use for storageid
- String to use for widget id and persistent storageStorageObject
public Widget(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, boolean storageFlag, java.lang.String id)
clientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port to use for server communicationsencoderClass
- Class to use for communications encodingdecoderClass
- Class to use for communications decodingstorageFlag
- Flag to determine whether storage should be used or notid
- String to use for widget id and persistent storageStorageObject
public Widget(int port, java.lang.String id, boolean storageFlag)
port
- Port to listen to for incoming messagesid
- Widget idstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Widget(int port, java.lang.String id)
port
- Port to listen to for incoming messagesid
- Widget idpublic Widget(java.lang.String id, boolean storageFlag)
id
- Widget idstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Widget(java.lang.String id)
id
- ID of the widgetMethod Detail |
protected abstract Attributes setAttributes()
protected abstract Callbacks setCallbacks()
protected abstract Services setServices()
protected java.lang.String getAttributeType(java.lang.String name)
name
- Name of the attribute to getprotected void setAttribute(java.lang.String name, java.lang.String type)
name
- Name of the attribute to settype
- Type of the attributeprotected boolean isAttribute(java.lang.String name)
name
- Name of the attribute to checkprotected boolean isCallback(java.lang.String name)
name
- Name of the callback to checkpublic void notify(java.lang.String event, java.lang.Object data)
event
- Name of the event occurringdata
- Object containing the relevant dataprotected void updateWidgetInformation()
protected abstract AttributeNameValues queryGenerator()
protected DataObject runWidgetMethod(DataObject data, java.lang.String error)
data
- DataObject containing the data for the methoderror
- String containing the incoming error valuepublic DataObject runUserMethod(DataObject data)
data
- DataObject containing the method to run and parametersQUERY
,
QUERY_VERSION
,
UPDATE_AND_QUERY
protected DataObject putData(DataObject data, java.lang.String error)
data
- DataObject containing the context data to writeerror
- String containing the incoming error valueprotected DataObject queryCallbacks(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error valueprotected DataObject queryAttributes(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error valueprotected DataObject queryServices(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error valueprotected DataObject queryWidget(DataObject query, boolean update, java.lang.String error)
query
- DataObject containing the query requestupdate
- Whether or not to acquire new dataerror
- String containing the incoming error valueprotected boolean canHandle(Attributes attributes)
attributes
- Attributes object containing attributes to checkprotected boolean canHandle(Attributes atts, Conditions conds)
atts
- List of attributes to checkconds
- List of Conditions to checkprotected boolean canHandle(AttributeFunctions atts, Conditions conds)
atts
- List of attributes to checkconds
- List of Conditions to checkprotected boolean canHandle(AttributeNameValues atts)
atts
- List of attributes to checkprotected DataObject executeService(DataObject request, java.lang.String error)
request
- DataObject containing the service requesterror
- String containing the incoming error valueprotected void sendToSubscribers(java.lang.String callback, AttributeNameValues atts)
callbackTag
- Context widget callback that was triggeredatts
- AttributeNameValues to send to subscribersdata
- DataObject version of attsBaseObject.userRequest(DataObject, String, String, int)
,
Subscribers
protected void processCallbackReply(DataObject result, Subscriber sub)
result
- DataObject containing the resultsub
- Subscriber that returned this replyprotected DataObject addSubscriber(DataObject sub, java.lang.String error)
sub
- DataObject containing the subscription informationerror
- String containing the incoming error valueSubscribers.addSubscriber(String,String,int,String,String,Conditions,Attributes)
protected DataObject removeSubscriber(DataObject sub, java.lang.String error)
sub
- DataObject containing the subscription informationerror
- String containing the incoming error valueSubscribers.removeSubscriber(String, String, String, String, String)
protected DataObject retrieveData(DataObject data, java.lang.String error)
data
- DataObject containing the subscription informationerror
- String containing the incoming error valueprotected void store(DataObject data)
data
- Data to storeStorageObject.store(DataObject)
protected void store(AttributeNameValues data)
data
- Data to storeStorageObject.store(AttributeNameValues)
protected void getNewOffset()
OffsetThread
protected long getNewOffsetNoDelay()
OffsetThread
protected java.lang.Long getCurrentTime()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |