| 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 ConfigPlatform implements Concept { |
| 31 | |
| 32 | /** list of options of type String */ |
| 33 | private List options = null; |
| 34 | /** list of arguments of type Argument */ |
| 35 | private List agentSpecifiers = null; |
| 36 | |
| 37 | /** |
| 38 | * Constructor |
| 39 | */ |
| 40 | public ConfigPlatform() { |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * add one option at a time |
| 45 | * @param option option to add |
| 46 | */ |
| 47 | public void addOption( String option ) { |
| 48 | if ( null == options ) { |
| 49 | options = new LinkedList(); |
| 50 | } |
| 51 | options.add( option ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @return Returns the options. |
| 56 | */ |
| 57 | public List getOptions() { |
| 58 | return options; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @param options The options to set. |
| 63 | */ |
| 64 | public void setOptions(List options) { |
| 65 | this.options = options; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * add one agent specifier at a time |
| 70 | * @param agentSpecifier agent specifier to add |
| 71 | */ |
| 72 | public void addAgentSpecifier( ConfigAgentSpecifier agentSpecifier ) { |
| 73 | if ( null == agentSpecifiers ) { |
| 74 | agentSpecifiers = new LinkedList(); |
| 75 | } |
| 76 | agentSpecifiers.add( agentSpecifier ); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * @param arguments The arguments to set. |
| 81 | */ |
| 82 | public void setAgentSpecifiers(List arguments) { |
| 83 | this.agentSpecifiers = arguments; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @return Returns the arguments. |
| 88 | */ |
| 89 | public List getAgentSpecifiers() { |
| 90 | return agentSpecifiers; |
| 91 | } |
| 92 | |
| 93 | /* (non-Javadoc) |
| 94 | * @see java.lang.Object#toString() |
| 95 | */ |
| 96 | public String toString() { |
| 97 | StringBuffer sb = new StringBuffer(); |
| 98 | sb.append( "Platform[" ); |
| 99 | if ( null != options ) { |
| 100 | sb.append("("); |
| 101 | Iterator optionI = options.iterator(); |
| 102 | boolean first = true; |
| 103 | while ( optionI.hasNext() ) { |
| 104 | if ( first ) { |
| 105 | first = false; |
| 106 | } |
| 107 | else { |
| 108 | sb.append(","); |
| 109 | } |
| 110 | sb.append( optionI.next().toString() ); |
| 111 | } |
| 112 | sb.append(")"); |
| 113 | } |
| 114 | if ( null != agentSpecifiers ) { |
| 115 | sb.append(","); |
| 116 | Iterator argumentsI = agentSpecifiers.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 | } |
| 128 | sb.append("]"); |
| 129 | return sb.toString(); |
| 130 | } |
| 131 | |
| 132 | } |