1 | // jademx - JADE management using JMX |
2 | // Copyright 2005 Caboodle Networks, Inc. |
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 (at your option) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
17 | |
18 | package jade.jademx.config.jademx.onto; |
19 | |
20 | import jade.content.Concept; |
21 | import jade.util.leap.Iterator; |
22 | import jade.util.leap.LinkedList; |
23 | import jade.util.leap.List; |
24 | |
25 | /** |
26 | * Class to represent an argument to an agent in the JademxConfigOntology. |
27 | * @author David Bernstein, <a href="http://www.caboodlenetworks.com" |
28 | * >Caboodle Networks, Inc.</a> |
29 | */ |
30 | public class ConfigAgentSpecifier implements Concept { |
31 | |
32 | /** agent name */ |
33 | private String name = null; |
34 | /** agent class */ |
35 | private String classname = null; |
36 | /** list of arguments of type Argument */ |
37 | private List arguments = null; |
38 | |
39 | /** |
40 | * Constructor |
41 | */ |
42 | public ConfigAgentSpecifier() { |
43 | } |
44 | |
45 | /** |
46 | * construct agent specifier with name and classname |
47 | * @param name agent's name |
48 | * @param classname agent's classname |
49 | */ |
50 | public ConfigAgentSpecifier( String name, String classname ) { |
51 | setName( name ); |
52 | setClassname( classname ); |
53 | } |
54 | |
55 | /** |
56 | * @return Returns the name. |
57 | */ |
58 | public String getName() { |
59 | return name; |
60 | } |
61 | |
62 | /** |
63 | * @param value The name to set. |
64 | */ |
65 | public void setName(String value) { |
66 | this.name = value; |
67 | } |
68 | |
69 | /** |
70 | * @return Returns the classname. |
71 | */ |
72 | public String getClassname() { |
73 | return classname; |
74 | } |
75 | |
76 | /** |
77 | * @param classname The classname to set. |
78 | */ |
79 | public void setClassname(String classname) { |
80 | this.classname = classname; |
81 | } |
82 | |
83 | /** |
84 | * add one argument at a time |
85 | * @param argument argument to add |
86 | */ |
87 | public void addArgument( ConfigArgument argument ) { |
88 | if ( null == arguments ) { |
89 | arguments = new LinkedList(); |
90 | } |
91 | arguments.add( argument ); |
92 | } |
93 | |
94 | /** |
95 | * @param arguments The arguments to set. |
96 | */ |
97 | public void setArguments(List arguments) { |
98 | this.arguments = arguments; |
99 | } |
100 | |
101 | /** |
102 | * @return Returns the arguments. |
103 | */ |
104 | public List getArguments() { |
105 | return arguments; |
106 | } |
107 | |
108 | /* (non-Javadoc) |
109 | * @see java.lang.Object#toString() |
110 | */ |
111 | public String toString() { |
112 | StringBuffer sb = new StringBuffer(); |
113 | sb.append( "AgentSpecifier[\""+name+"\""+("["+classname)+"]" ); |
114 | if ( null != arguments ) { |
115 | sb.append("("); |
116 | Iterator argumentsI = arguments.iterator(); |
117 | boolean first = true; |
118 | while ( argumentsI.hasNext() ) { |
119 | if ( first ) { |
120 | first = false; |
121 | } |
122 | else { |
123 | sb.append(","); |
124 | } |
125 | sb.append( argumentsI.next().toString() ); |
126 | } |
127 | sb.append(")"); |
128 | } |
129 | sb.append("]"); |
130 | return sb.toString(); |
131 | } |
132 | } |