KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > scheduler > ScheduleItem


1 /*
2  * Copyright (C) 2001 - 2005 ScalAgent Distributed Technologies
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): ScalAgent Distributed Technologies
20  * Contributor(s):
21  */

22 package com.scalagent.scheduler;
23
24 import java.io.*;
25 import java.util.*;
26 import fr.dyade.aaa.agent.*;
27
28
29 /**
30  * Implements a double linked list of <code>ScheduleEvent</code> objects.
31  * Both ends are marked with a <code>null</code> value. Events are ordered in
32  * increasing order of dates.
33  * <p>
34  * The <code>status</code> field associated with the <code>ScheduleEvent</code>
35  * is used by the <code>Scheduler</code> agent, and is set to <code>true</code>
36  * when the <code>true</code> <code>Condition</code> notification has been sent
37  * and the <code>Scheduler</code> agent waits for the duration to expire before
38  * sending the <code>false</code> condition and resetting the field.
39  *
40  * @see Scheduler
41  * @see ScheduleEvent
42  */

43 public class ScheduleItem implements Serializable {
44   /** may be of a derived class */
45   ScheduleEvent event;
46   /** next schedule date */
47   Date date;
48   /** last sent condition status */
49   boolean status;
50   /** previous item, null terminated */
51   ScheduleItem prev;
52   /** next item, null terminated */
53   ScheduleItem next;
54
55   /**
56    * Creates an item.
57    *
58    * @param event event to schedule
59    */

60   public ScheduleItem(ScheduleEvent event) {
61     this.event = event;
62     date = null;
63     status = false;
64     prev = null;
65     next = null;
66   }
67
68   /**
69    * Provides a string image for this object.
70    *
71    * @return a string image for this object
72    */

73   public String JavaDoc toString() {
74     StringBuffer JavaDoc output = new StringBuffer JavaDoc();
75     output.append("(");
76     for (ScheduleItem item = this; item != null; item = item.next) {
77       output.append("(event=");
78       output.append(item.event.toString());
79       output.append(",date=");
80       output.append(item.date);
81       output.append(",status=");
82       output.append(item.status);
83       output.append("),");
84     }
85     output.append("null)");
86     return output.toString();
87   }
88 }
89
Popular Tags