KickJava   Java API By Example, From Geeks To Geeks.

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


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 fr.dyade.aaa.agent.*;
25 import java.io.*;
26
27 /**
28  * Structure to keep registered listeners for a scheduler condition.
29  *
30  * @see Scheduler
31  */

32 public class ConditionItem implements Serializable {
33   /** condition name */
34   String JavaDoc name;
35   /** list of registered agents for this event */
36   RoleMultiple listeners;
37   /** next item, <code>null</code> terminated, in lexicographic order of name */
38   ConditionItem next;
39
40   /**
41    * Initializes object to be decoded.
42    */

43   public ConditionItem() {
44     this(null);
45   }
46
47   /**
48    * Constructor.
49    *
50    * @param name condition name
51    * @param listeners list of registered agents for this event
52    */

53   public ConditionItem(String JavaDoc name, RoleMultiple listeners) {
54     this.name = name;
55     if (listeners != null)
56       this.listeners = listeners;
57     else
58       this.listeners = new RoleMultiple();
59     next = null;
60   }
61
62   /**
63    * Constructor with default <code>null</code> value for
64    * <code>listeners<code>.
65    *
66    * @param name condition name
67    */

68   public ConditionItem(String JavaDoc name) {
69     this(name, null);
70   }
71
72   /**
73    * Provides a string image for this object.
74    *
75    * @return a string image for this object
76    */

77   public String JavaDoc toString() {
78     StringBuffer JavaDoc output = new StringBuffer JavaDoc();
79     output.append("(");
80     for (ConditionItem item = this; item != null; item = item.next) {
81       output.append("(name=");
82       output.append(item.name);
83       output.append(",listeners=");
84       output.append(item.listeners);
85       output.append("),");
86     }
87     output.append("null)");
88     return output.toString();
89   }
90 }
91
Popular Tags