KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > Role


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

20
21 package fr.dyade.aaa.agent;
22
23 import java.io.*;
24
25 /**
26  * A role wraps an AgentId. It is identified by a name.
27  */

28 public class Role implements Serializable {
29     /**
30      * The wrapped <code>AgentId</code>.
31      */

32     private AgentId listener;
33
34     /**
35      * The role name.
36      */

37     private String JavaDoc name;
38
39     /**
40      * Creates a new role with the specified name.
41      * @param name the role name.
42      */

43     public Role(String JavaDoc name) {
44     this.name= name;
45     }
46
47     /**
48      * Creates a new role with the specified name and AgentId.
49      * @param name the role name.
50      * @param listener the wrapped <code>AgentId</code>.
51      */

52     public Role(String JavaDoc name, AgentId listener) {
53     this(name);
54     this.listener = listener;
55     }
56
57     /**
58      * Sets the wrapped <code>AgentId</code>.
59      * @param listener the wrapped <code>AgentId</code>.
60      */

61     public void setListener(AgentId listener) {
62     this.listener = listener;
63     }
64
65     /**
66      * Returns the wrapped <code>AgentId</code>.
67      */

68     public AgentId getListener() {
69     return listener;
70     }
71
72     /**
73      * Returns the role name.
74      */

75     public String JavaDoc getName() {
76     return name;
77     }
78
79     /**
80      * Sets the role name.
81      * @param name the role name.
82      */

83     public void setName(String JavaDoc name) {
84     this.name = name;
85     }
86
87     public String JavaDoc toString() {
88       StringBuffer JavaDoc output = new StringBuffer JavaDoc();
89       output.append("(");
90       output.append(super.toString());
91       output.append(",name=" + name);
92       output.append(",listener=" + listener);
93       output.append(")");
94       return output.toString();
95     }
96 }
97
Popular Tags