Source Code Cross Referenced for Arguments.java in  » Testing » jakarta-jmeter » org » apache » jmeter » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jakarta jmeter » org.apache.jmeter.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.config;
020:
021:        import java.io.Serializable;
022:        import java.util.ArrayList;
023:        import java.util.HashMap;
024:        import java.util.List;
025:        import java.util.Map;
026:
027:        import org.apache.jmeter.testelement.property.CollectionProperty;
028:        import org.apache.jmeter.testelement.property.PropertyIterator;
029:        import org.apache.jmeter.testelement.property.TestElementProperty;
030:
031:        // Mark Walsh, 2002-08-03 add method:
032:        // addArgument(String name, Object value, Object metadata)
033:        // Modify methods:
034:        // toString(), addEmptyArgument(), addArgument(String name, Object value)
035:
036:        /**
037:         * A set of Argument objects.
038:         * 
039:         */
040:        public class Arguments extends ConfigTestElement implements 
041:                Serializable {
042:            /** The name of the property used to store the arguments. */
043:            public static final String ARGUMENTS = "Arguments.arguments"; //$NON-NLS-1$
044:
045:            /**
046:             * Create a new Arguments object with no arguments.
047:             */
048:            public Arguments() {
049:                setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
050:            }
051:
052:            /**
053:             * Get the arguments.
054:             * 
055:             * @return the arguments
056:             */
057:            public CollectionProperty getArguments() {
058:                return (CollectionProperty) getProperty(ARGUMENTS);
059:            }
060:
061:            /**
062:             * Clear the arguments.
063:             */
064:            public void clear() {
065:                super .clear();
066:                setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
067:            }
068:
069:            /**
070:             * Set the list of arguments. Any existing arguments will be lost.
071:             * 
072:             * @param arguments
073:             *            the new arguments
074:             */
075:            public void setArguments(List arguments) {
076:                setProperty(new CollectionProperty(ARGUMENTS, arguments));
077:            }
078:
079:            /**
080:             * Get the arguments as a Map. Each argument name is used as the key, and
081:             * its value as the value.
082:             * 
083:             * @return a new Map with String keys and values containing the arguments
084:             */
085:            public Map getArgumentsAsMap() {
086:                PropertyIterator iter = getArguments().iterator();
087:                Map argMap = new HashMap();
088:                while (iter.hasNext()) {
089:                    Argument arg = (Argument) iter.next().getObjectValue();
090:                    // Because CollectionProperty.mergeIn will not prevent adding two
091:                    // properties of the same name, we need to select the first value so
092:                    // that this element's values prevail over defaults provided by
093:                    // configuration
094:                    // elements:
095:                    if (!argMap.containsKey(arg.getName()))
096:                        argMap.put(arg.getName(), arg.getValue());
097:                }
098:                return argMap;
099:            }
100:
101:            /**
102:             * Add a new argument with the given name and value.
103:             * 
104:             * @param name
105:             *            the name of the argument
106:             * @param value
107:             *            the value of the argument
108:             */
109:            public void addArgument(String name, String value) {
110:                addArgument(new Argument(name, value, null));
111:            }
112:
113:            /**
114:             * Add a new argument.
115:             * 
116:             * @param arg
117:             *            the new argument
118:             */
119:            public void addArgument(Argument arg) {
120:                TestElementProperty newArg = new TestElementProperty(arg
121:                        .getName(), arg);
122:                if (isRunningVersion()) {
123:                    this .setTemporary(newArg);
124:                }
125:                getArguments().addItem(newArg);
126:            }
127:
128:            /**
129:             * Add a new argument with the given name, value, and metadata.
130:             * 
131:             * @param name
132:             *            the name of the argument
133:             * @param value
134:             *            the value of the argument
135:             * @param metadata
136:             *            the metadata for the argument
137:             */
138:            public void addArgument(String name, String value, String metadata) {
139:                addArgument(new Argument(name, value, metadata));
140:            }
141:
142:            /**
143:             * Get a PropertyIterator of the arguments.
144:             * 
145:             * @return an iteration of the arguments
146:             */
147:            public PropertyIterator iterator() {
148:                return getArguments().iterator();
149:            }
150:
151:            /**
152:             * Create a string representation of the arguments.
153:             * 
154:             * @return the string representation of the arguments
155:             */
156:            public String toString() {
157:                StringBuffer str = new StringBuffer();
158:                PropertyIterator iter = getArguments().iterator();
159:                while (iter.hasNext()) {
160:                    Argument arg = (Argument) iter.next().getObjectValue();
161:                    final String metaData = arg.getMetaData();
162:                    str.append(arg.getName());
163:                    if (metaData == null) {
164:                        str.append("="); //$NON-NLS-1$
165:                    } else {
166:                        str.append(metaData);
167:                    }
168:                    str.append(arg.getValue());
169:                    if (iter.hasNext()) {
170:                        str.append("&"); //$NON-NLS-1$
171:                    }
172:                }
173:                return str.toString();
174:            }
175:
176:            /**
177:             * Remove the specified argument from the list.
178:             * 
179:             * @param row
180:             *            the index of the argument to remove
181:             */
182:            public void removeArgument(int row) {
183:                if (row < getArguments().size()) {
184:                    getArguments().remove(row);
185:                }
186:            }
187:
188:            /**
189:             * Remove the specified argument from the list.
190:             * 
191:             * @param arg
192:             *            the argument to remove
193:             */
194:            public void removeArgument(Argument arg) {
195:                PropertyIterator iter = getArguments().iterator();
196:                while (iter.hasNext()) {
197:                    Argument item = (Argument) iter.next().getObjectValue();
198:                    if (arg.equals(item)) {
199:                        iter.remove();
200:                    }
201:                }
202:            }
203:
204:            /**
205:             * Remove the argument with the specified name.
206:             * 
207:             * @param argName
208:             *            the name of the argument to remove
209:             */
210:            public void removeArgument(String argName) {
211:                PropertyIterator iter = getArguments().iterator();
212:                while (iter.hasNext()) {
213:                    Argument arg = (Argument) iter.next().getObjectValue();
214:                    if (arg.getName().equals(argName)) {
215:                        iter.remove();
216:                    }
217:                }
218:            }
219:
220:            /**
221:             * Remove all arguments from the list.
222:             */
223:            public void removeAllArguments() {
224:                getArguments().clear();
225:            }
226:
227:            /**
228:             * Add a new empty argument to the list. The new argument will have the
229:             * empty string as its name and value, and null metadata.
230:             */
231:            public void addEmptyArgument() {
232:                addArgument(new Argument("", "", null));
233:            }
234:
235:            /**
236:             * Get the number of arguments in the list.
237:             * 
238:             * @return the number of arguments
239:             */
240:            public int getArgumentCount() {
241:                return getArguments().size();
242:            }
243:
244:            /**
245:             * Get a single argument.
246:             * 
247:             * @param row
248:             *            the index of the argument to return.
249:             * @return the argument at the specified index, or null if no argument
250:             *         exists at that index.
251:             */
252:            public Argument getArgument(int row) {
253:                Argument argument = null;
254:
255:                if (row < getArguments().size()) {
256:                    argument = (Argument) getArguments().get(row)
257:                            .getObjectValue();
258:                }
259:
260:                return argument;
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.