home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 2.4 KB | 84 lines |
- /*
- * @(#DataBusEvent.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
- //This class specifies an IB event for a DataItem. The IB event's parameters include
- // the data item name, which should be descriptive enough to allow a data consumer to decide whether to obtain
- // the data item.
-
- // the event type, which is one of DATA_AVAILABLE, DATA_REVOKED, or DATA_REQUEST.
-
- // the object that created the event.
- // the data item referred to by the event
-
- package symantec.itools.db.beans.binding.databus;
-
- public class DataBusEvent extends java.util.EventObject
- {
- //DATA_AVAILABLE
- //Event type sent by a source to announce the availability of the named DataItem.
- public static final int DATA_AVAILABLE =0;
-
- //DATA_REVOKED
- //Event type sent by a source to indicate that an existing DataItem is no longer available.
- public static final int DATA_REVOKED =1;
-
- //DATA_REQUEST
- //Event type sent by a consumer to request the DataItem matching a specified dataItemName,
- //from the sources on the bus.
- public static final int DATA_REQUEST =2;
-
- private int ty;
- private String itNa;
- private DataItem di;
-
- public DataBusEvent(int type, String itemName, Object source) throws InvalidType
- {
- super(source);
- if ((type < DATA_AVAILABLE) || ( type > DATA_REQUEST))
- throw new InvalidType();
- else
- ty=type;
- itNa=itemName;
- }
-
- public DataBusEvent(int type, String itemName, Object source, DataItem d)throws InvalidType
- {
- super(source);
- if ((type < DATA_AVAILABLE) || ( type > DATA_REQUEST))
- throw new InvalidType();
- else
- ty=type;
- itNa=itemName;
- di=d;
- }
- //These methods construct an IB event object for a data item. The first constructor leaves the item data
- //to be filled in later, when requested, while the second one supplies it.
-
- public DataItem getDataItem()
- {
- return di;
- }
-
- public void setDataItem(DataItem d)
- //These methods are for the source and consumer of the data to set and get the data item associated
- //with the event.
- {
- di=d;
- }
-
- public int getEventType()
- {
- return ty;
- }
-
- public String getDataItemName()
- //These methods allow the data consumer to look at the event type and data item name to find out what
- //kind of data the data item holds.
- {
- return itNa;
- }
- }