[jboss-svn-commits] JBL Code SVN: r16848 - labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Nov 26 16:44:22 EST 2007


Author: tirelli
Date: 2007-11-26 16:44:21 -0500 (Mon, 26 Nov 2007)
New Revision: 16848

Modified:
   labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java
Log:
JBRULES-1332: adding event fact handle specific attributes: startTimestamp, duration and endTimestamp

Modified: labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java	2007-11-26 21:29:48 UTC (rev 16847)
+++ labs/jbossrules/branches/temporal_rete/drools-core/src/main/java/org/drools/common/EventFactHandle.java	2007-11-26 21:44:21 UTC (rev 16848)
@@ -5,6 +5,9 @@
 public class EventFactHandle extends DefaultFactHandle {
 
     private static final long serialVersionUID = 5997141759543399455L;
+    
+    private long startTimestamp;
+    private long duration;
 
     // ----------------------------------------------------------------------
     // Constructors
@@ -35,6 +38,27 @@
     }
     
     /**
+     * Creates a new event fact handle.
+     * 
+     * @param id this event fact handle ID
+     * @param object the event object encapsulated in this event fact handle
+     * @param recency the recency of this event fact handle
+     * @param timestamp the timestamp of the occurence of this event
+     * @param duration the duration of this event. May be 0 (zero) in case this is a primitive event.
+     */
+    public EventFactHandle( final long id, 
+                            final Object object,
+                            final long recency,
+                            final long timestamp,
+                            final long duration ) {
+        super( id,
+               object, 
+               recency );
+        this.startTimestamp = timestamp;
+        this.duration = duration;
+    }
+    
+    /**
      * @see FactHandle
      */
     public String toExternalForm() {
@@ -55,4 +79,33 @@
     public boolean isEvent() {
         return true;
     }
+
+    /**
+     * Returns the timestamp of the occurrence of this event.
+     * @return
+     */
+    public long getStartTimestamp() {
+        return startTimestamp;
+    }
+
+    /**
+     * Returns the duration of this event. In case this is a primitive event, 
+     * returns 0 (zero).
+     * 
+     * @return
+     */
+    public long getDuration() {
+        return duration;
+    }
+
+    /**
+     * Returns the end timestamp for this event. This is the same as:
+     * 
+     * startTimestamp + duration
+     * 
+     * @return
+     */
+    public long getEndTimestamp() {
+        return this.startTimestamp + this.duration;
+    }
 }




More information about the jboss-svn-commits mailing list