[MOBY-guts] biomoby commit
Martin Senger
senger at pub.open-bio.org
Sat Oct 22 01:38:05 UTC 2005
senger
Fri Oct 21 21:38:04 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event
In directory pub.open-bio.org:/tmp/cvs-serv3384/src/main/org/biomoby/shared/event
Modified Files:
NotificationEvent.java Notifier.java
Log Message:
moby-live/Java/src/main/org/biomoby/shared/event NotificationEvent.java,1.1,1.2 Notifier.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/NotificationEvent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/NotificationEvent.java 2005/10/12 11:17:59 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/NotificationEvent.java 2005/10/22 01:38:04 1.2
@@ -13,15 +13,16 @@
/**
* An event fired by various Moby components to inform that something
* has happened. Typical usage is for monitoring access to a Biomoby
- * registry (how many entities yet to read, and which one was just
+ * registry (how many entities to read, and which one was just
* read). <p>
*
* Each notification event points to its source (this is inherited
- * from a usual Java's EventObject). Additionally, it has its type (a
- * string value, usually taken from a list defined in this class), a
- * message (whose format may be detremined by the notification type),
- * and optionally an object with more details (again, its presence or
- * absence may depend on the notification type). <p>
+ * from a usual Java's EventObject). Additionally, it has its type (an
+ * integer value, preferably taken from a list defined in interface
+ * {@link org.biomoby.shared.event.Notifier}), a message (whose format
+ * may be determined by the notification type), and optionally an
+ * object with more details (again, its presence or absence may depend
+ * on the notification type). <p>
*
* @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
* @version $Id$
@@ -30,7 +31,7 @@
public class NotificationEvent
extends EventObject {
- private String type;
+ private int type;
private String message;
private Object details;
@@ -45,10 +46,10 @@
* A usual constructor, setting notification type and a message.
********************************************************************/
public NotificationEvent (Object source,
- String type, String message) {
+ int type, String message) {
this (source);
this.type = type;
- this.message = message;
+ this.message = (message == null ? "" : message);
}
/*********************************************************************
@@ -56,7 +57,7 @@
* details.
********************************************************************/
public NotificationEvent (Object source,
- String type, String message,
+ int type, String message,
Object details) {
this (source, type, message);
this.details = details;
@@ -65,7 +66,7 @@
/*********************************************************************
* Return a type of this notification event.
********************************************************************/
- public String getType() {
+ public int getType() {
return type;
}
@@ -88,9 +89,15 @@
*
********************************************************************/
public String toString() {
+ String typeStr = null;
+ try {
+ typeStr = typeTexts [type];
+ } catch (Exception e) {
+ typeStr = "" + type;
+ }
StringBuffer buf = new StringBuffer (100);
buf.append ("[");
- buf.append ("Type=" + type);
+ buf.append (typeStr);
buf.append (", Message=" + message);
if (details != null)
buf.append (", Details=" + details.getClass().getName());
@@ -98,4 +105,35 @@
return new String (buf);
}
+ static final String[] typeTexts = new String[] {
+ "data-type-start",
+ "data-type-count",
+ "data-type-loading",
+ "data-type-loaded",
+ "data-type-end",
+ "service-type-start",
+ "service-type-count",
+ "service-type-loading",
+ "service-type-loaded",
+ "service-type-end",
+ "namespace-start",
+ "namespace-count",
+ "namespace-loading",
+ "namespace-loaded",
+ "namespace-end",
+ "authority-start",
+ "authority-count",
+ "authority-loading",
+ "authority-loaded",
+ "authority-end",
+ "data-type-reset",
+ "service-type-reset",
+ "namespace-reset",
+ "authority-reset",
+ "data-type-cancel",
+ "service-type-cancel",
+ "namespace-cancel",
+ "authority-cancel"
+ };
+
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/Notifier.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/Notifier.java 2005/10/12 11:36:59 1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/event/Notifier.java 2005/10/22 01:38:04 1.3
@@ -16,21 +16,46 @@
public interface Notifier {
- static final String DATA_TYPE_COUNT = "data-type-count";
- static final String DATA_TYPE_LOADING = "data-type-loading";
- static final String DATA_TYPE_LOADED = "data-type-loaded";
-
- static final String SERVICE_TYPE_COUNT = "service-type-count";
- static final String SERVICE_TYPE_LOADING = "service-type-loading";
- static final String SERVICE_TYPE_LOADED = "service-type-loaded";
-
- static final String NAMESPACE_COUNT = "namespace-count";
- static final String NAMESPACE_LOADING = "namespace-loading";
- static final String NAMESPACE_LOADED = "namespace-loaded";
-
- static final String AUTHORITY_COUNT = "authority-count";
- static final String AUTHORITY_LOADING = "authority-loading";
- static final String AUTHORITY_LOADED = "authority-loaded";
+ static final int DATA_TYPES_START = 0;
+ static final int DATA_TYPES_COUNT = 1;
+ static final int DATA_TYPE_LOADING = 2;
+ static final int DATA_TYPE_LOADED = 3;
+ static final int DATA_TYPES_END = 4;
+
+ static final int SERVICE_TYPES_START = 5;
+ static final int SERVICE_TYPES_COUNT = 6;
+ static final int SERVICE_TYPE_LOADING = 7;
+ static final int SERVICE_TYPE_LOADED = 8;
+ static final int SERVICE_TYPES_END = 9;
+
+ static final int NAMESPACES_START = 10;
+ static final int NAMESPACES_COUNT = 11;
+ static final int NAMESPACE_LOADING = 12;
+ static final int NAMESPACE_LOADED = 13;
+ static final int NAMESPACES_END = 14;
+
+ static final int AUTHORITIES_START = 15;
+ static final int AUTHORITIES_COUNT = 16;
+ static final int AUTHORITY_LOADING = 17;
+ static final int AUTHORITY_LOADED = 18;
+ static final int AUTHORITIES_END = 19;
+
+ static final int DATA_TYPES_RESET = 20;
+ static final int SERVICE_TYPES_RESET = 21;
+ static final int NAMESPACES_RESET = 22;
+ static final int AUTHORITIES_RESET = 23;
+
+ static final int DATA_TYPES_CANCELLED = 24;
+ static final int SERVICE_TYPES_CANCELLED = 25;
+ static final int NAMESPACES_CANCELLED = 26;
+ static final int AUTHORITIES_CANCELLED = 27;
+
+
+
+ static final int SIGNAL_CANCEL_DATA_TYPES = 1;
+ static final int SIGNAL_CANCEL_SERVICE_TYPES = 2;
+ static final int SIGNAL_CANCEL_SERVICES = 3;
+ static final int SIGNAL_CANCEL_NAMESPACES = 4;
/*********************************************************************
* Adds the specified notification listener to receive
@@ -42,6 +67,15 @@
void addNotificationListener (NotificationListener l);
/*********************************************************************
+ * Adds the specified notification listeners to receive
+ * notification events from the class that implements this
+ * interface. <p>
+ *
+ * @param l notification listeners to be added
+ ********************************************************************/
+ void addNotificationListeners (NotificationListener[] l);
+
+ /*********************************************************************
* Removes the specified notification listener so that it no
* longer receives notification events from the class that
* implements this interface. <p>
@@ -51,6 +85,15 @@
void removeNotificationListener (NotificationListener l);
/*********************************************************************
+ * Removes the specified notification listeners so that they no
+ * longer receive notification events from the class that
+ * implements this interface. <p>
+ *
+ * @param l notification listeners to be removed
+ ********************************************************************/
+ void removeNotificationListeners (NotificationListener[] l);
+
+ /*********************************************************************
* Returns an array of all the NotificationListeners added to the
* class that implements this interface. <p>
*
@@ -59,4 +102,19 @@
********************************************************************/
NotificationListener[] getNotificationListeners();
+ /*********************************************************************
+ * Call the notifier and signal that it can stop loading data (or
+ * whatever it is doing). <p>
+ *
+ * @param signal identify what to stop doing (some usual values of
+ * this signal are defined elsewhere in this interface with names
+ * starting by <tt>SIGNAL_</tt>)
+ ********************************************************************/
+ void callback (int callbackSignal);
+
+ /*********************************************************************
+ *
+ ********************************************************************/
+ void fireEvent (int type, Object message, Object details);
+
}
More information about the MOBY-guts
mailing list