public class Arguments extends ConfigTestElement implements Serializable { /** The name of the property used to store the arguments. */ public static final String ARGUMENTS = "Arguments.arguments"; //$NON-NLS-1$ /** * Create a new Arguments object with no arguments. */ public Arguments() { setProperty(new CollectionProperty(ARGUMENTS, new ArrayList())); } /** * Get the arguments. * * @return the arguments */ public CollectionProperty getArguments() { return (CollectionProperty) getProperty(ARGUMENTS); } /** * Clear the arguments. */ public void clear() { super.clear(); setProperty(new CollectionProperty(ARGUMENTS, new ArrayList())); } /** * Set the list of arguments. Any existing arguments will be lost. * * @param arguments * the new arguments */ public void setArguments(List arguments) { setProperty(new CollectionProperty(ARGUMENTS, arguments)); } /** * Get the arguments as a Map. Each argument name is used as the key, and * its value as the value. * * @return a new Map with String keys and values containing the arguments */ public Map getArgumentsAsMap() { PropertyIterator iter = getArguments().iterator(); Map argMap = new LinkedHashMap(); while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); // Because CollectionProperty.mergeIn will not prevent adding two // properties of the same name, we need to select the first value so // that this element's values prevail over defaults provided by // configuration // elements: if (!argMap.containsKey(arg.getName())) { argMap.put(arg.getName(), arg.getValue()); } } return argMap; } /** * Add a new argument with the given name and value. * * @param name * the name of the argument * @param value * the value of the argument */ public void addArgument(String name, String value) { addArgument(new Argument(name, value, null)); } /** * Add a new argument. * * @param arg * the new argument */ public void addArgument(Argument arg) { TestElementProperty newArg = new TestElementProperty(arg.getName(), arg); if (isRunningVersion()) { this.setTemporary(newArg); } getArguments().addItem(newArg); } /** * Add a new argument with the given name, value, and metadata. * * @param name * the name of the argument * @param value * the value of the argument * @param metadata * the metadata for the argument */ public void addArgument(String name, String value, String metadata) { addArgument(new Argument(name, value, metadata)); } /** * Get a PropertyIterator of the arguments. * * @return an iteration of the arguments */ public PropertyIterator iterator() { return getArguments().iterator(); } /** * Create a string representation of the arguments. * * @return the string representation of the arguments */ public String toString() { StringBuffer str = new StringBuffer(); PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); final String metaData = arg.getMetaData(); str.append(arg.getName()); if (metaData == null) { str.append("="); //$NON-NLS-1$ } else { str.append(metaData); } str.append(arg.getValue()); if (iter.hasNext()) { str.append("&"); //$NON-NLS-1$ } } return str.toString(); } /** * Remove the specified argument from the list. * * @param row * the index of the argument to remove */ public void removeArgument(int row) { if (row < getArguments().size()) { getArguments().remove(row); } } /** * Remove the specified argument from the list. * * @param arg * the argument to remove */ public void removeArgument(Argument arg) { PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { Argument item = (Argument) iter.next().getObjectValue(); if (arg.equals(item)) { iter.remove(); } } } /** * Remove the argument with the specified name. * * @param argName * the name of the argument to remove */ public void removeArgument(String argName) { PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); if (arg.getName().equals(argName)) { iter.remove(); } } } /** * Remove all arguments from the list. */ public void removeAllArguments() { getArguments().clear(); } /** * Add a new empty argument to the list. The new argument will have the * empty string as its name and value, and null metadata. */ public void addEmptyArgument() { addArgument(new Argument("", "", null)); } /** * Get the number of arguments in the list. * * @return the number of arguments */ public int getArgumentCount() { return getArguments().size(); } /** * Get a single argument. * * @param row * the index of the argument to return. * @return the argument at the specified index, or null if no argument * exists at that index. */ public Argument getArgument(int row) { Argument argument = null; if (row < getArguments().size()) { argument = (Argument) getArguments().get(row).getObjectValue(); } return argument;
public class LDAPArguments extends ConfigTestElement implements Serializable { /** The name of the property used to store the arguments. */ public static final String ARGUMENTS = "Arguments.arguments"; //$NON-NLS$ /** * Create a new Arguments object with no arguments. */ public LDAPArguments() { setProperty(new CollectionProperty(ARGUMENTS, new ArrayList())); } /** * Get the arguments. * * @return the arguments */ public CollectionProperty getArguments() { return (CollectionProperty) getProperty(ARGUMENTS); } /** * Clear the arguments. */ public void clear() { super.clear(); setProperty(new CollectionProperty(ARGUMENTS, new ArrayList())); } /** * Set the list of arguments. Any existing arguments will be lost. * * @param arguments * the new arguments */ public void setArguments(List arguments) { setProperty(new CollectionProperty(ARGUMENTS, arguments)); } /** * Get the arguments as a Map. Each argument name is used as the key, and * its value as the value. * * @return a new Map with String keys and values containing the arguments */ public Map getArgumentsAsMap() { PropertyIterator iter = getArguments().iterator(); Map argMap = new HashMap(); while (iter.hasNext()) { LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue(); argMap.put(arg.getName(), arg.getValue()); } return argMap; } /** * Add a new argument with the given name and value. * * @param name * the name of the argument * @param value * the value of the argument */ public void addArgument(String name, String value, String opcode) { addArgument(new LDAPArgument(name, value, opcode, null)); } /** * Add a new argument. * * @param arg * the new argument */ public void addArgument(LDAPArgument arg) { TestElementProperty newArg = new TestElementProperty(arg.getName(), arg); if (isRunningVersion()) { this.setTemporary(newArg); } getArguments().addItem(newArg); } /** * Add a new argument with the given name, value, and metadata. * * @param name * the name of the argument * @param value * the value of the argument * @param metadata * the metadata for the argument */ public void addArgument(String name, String value, String opcode, String metadata) { addArgument(new LDAPArgument(name, value, opcode, metadata)); } /** * Get a PropertyIterator of the arguments. * * @return an iteration of the arguments */ public PropertyIterator iterator() { return getArguments().iterator(); } /** * Create a string representation of the arguments. * * @return the string representation of the arguments */ public String toString() { StringBuffer str = new StringBuffer(); PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue(); final String metaData = arg.getMetaData(); str.append(arg.getName()); if (metaData == null) { str.append("="); //$NON-NLS$ } else { str.append(metaData); } str.append(arg.getValue()); if (iter.hasNext()) { str.append("&"); //$NON-NLS$ } } return str.toString(); } /** * Remove the specified argument from the list. * * @param row * the index of the argument to remove */ public void removeArgument(int row) { if (row < getArguments().size()) { getArguments().remove(row); } } /** * Remove the specified argument from the list. * * @param arg * the argument to remove */ public void removeArgument(LDAPArgument arg) { PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { LDAPArgument item = (LDAPArgument) iter.next().getObjectValue(); if (arg.equals(item)) { iter.remove(); } } } /** * Remove the argument with the specified name. * * @param argName * the name of the argument to remove */ public void removeArgument(String argName) { PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue(); if (arg.getName().equals(argName)) { iter.remove(); } } } /** * Remove all arguments from the list. */ public void removeAllArguments() { getArguments().clear(); } /** * Add a new empty argument to the list. The new argument will have the * empty string as its name and value, and null metadata. */ public void addEmptyArgument() { addArgument(new LDAPArgument("", "", "", null)); } /** * Get the number of arguments in the list. * * @return the number of arguments */ public int getArgumentCount() { return getArguments().size(); } /** * Get a single argument. * * @param row * the index of the argument to return. * @return the argument at the specified index, or null if no argument * exists at that index. */ public LDAPArgument getArgument(int row) { LDAPArgument argument = null; if (row < getArguments().size()) { argument = (LDAPArgument) getArguments().get(row).getObjectValue(); } return argument;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/config/Arguments.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/ldap/config/gui/LDAPArguments.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class Arguments extends ConfigTestElement implements Serializable {
1
public class LDAPArguments extends ConfigTestElement implements Serializable {
2
	/** The name of the property used to store the arguments. */
2
	/** The name of the property used to store the arguments. */
3
	public static final String ARGUMENTS = "Arguments.arguments"; //$NON-NLS-1$
3
	public static final String ARGUMENTS = "Arguments.arguments"; //$NON-NLS$
4
	/**
4
	/**
5
	 * Create a new Arguments object with no arguments.
5
	 * Create a new Arguments object with no arguments.
6
	 */
6
	 */
7
	public Arguments() {
7
	public LDAPArguments() {
8
		setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
8
		setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
9
	}
9
	}
10
	/**
10
	/**
11
	 * Get the arguments.
11
	 * Get the arguments.
12
	 * 
12
	 * 
13
	 * @return the arguments
13
	 * @return the arguments
14
	 */
14
	 */
15
	public CollectionProperty getArguments() {
15
	public CollectionProperty getArguments() {
16
		return (CollectionProperty) getProperty(ARGUMENTS);
16
		return (CollectionProperty) getProperty(ARGUMENTS);
17
	}
17
	}
18
	/**
18
	/**
19
	 * Clear the arguments.
19
	 * Clear the arguments.
20
	 */
20
	 */
21
	public void clear() {
21
	public void clear() {
22
		super.clear();
22
		super.clear();
23
		setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
23
		setProperty(new CollectionProperty(ARGUMENTS, new ArrayList()));
24
	}
24
	}
25
	/**
25
	/**
26
	 * Set the list of arguments. Any existing arguments will be lost.
26
	 * Set the list of arguments. Any existing arguments will be lost.
27
	 * 
27
	 * 
28
	 * @param arguments
28
	 * @param arguments
29
	 *            the new arguments
29
	 *            the new arguments
30
	 */
30
	 */
31
	public void setArguments(List arguments) {
31
	public void setArguments(List arguments) {
32
		setProperty(new CollectionProperty(ARGUMENTS, arguments));
32
		setProperty(new CollectionProperty(ARGUMENTS, arguments));
33
	}
33
	}
34
	/**
34
	/**
35
	 * Get the arguments as a Map. Each argument name is used as the key, and
35
	 * Get the arguments as a Map. Each argument name is used as the key, and
36
	 * its value as the value.
36
	 * its value as the value.
37
	 * 
37
	 * 
38
	 * @return a new Map with String keys and values containing the arguments
38
	 * @return a new Map with String keys and values containing the arguments
39
	 */
39
	 */
40
	public Map getArgumentsAsMap() {
40
	public Map getArgumentsAsMap() {
41
		PropertyIterator iter = getArguments().iterator();
41
		PropertyIterator iter = getArguments().iterator();
42
		Map argMap = new LinkedHashMap();
42
		Map argMap = new HashMap();
43
		while (iter.hasNext()) {
43
		while (iter.hasNext()) {
44
			Argument arg = (Argument) iter.next().getObjectValue();
44
			LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
45
			// Because CollectionProperty.mergeIn will not prevent adding two
45
			
46
			// properties of the same name, we need to select the first value so
47
			// that this element's values prevail over defaults provided by
48
			// configuration
49
			// elements:
50
			if (!argMap.containsKey(arg.getName())) {
51
			    argMap.put(arg.getName(), arg.getValue());
46
argMap.put(arg.getName(), arg.getValue());
52
			}
47
		
53
		}
48
}
54
		return argMap;
49
		return argMap;
55
	}
50
	}
56
	/**
51
	/**
57
	 * Add a new argument with the given name and value.
52
	 * Add a new argument with the given name and value.
58
	 * 
53
	 * 
59
	 * @param name
54
	 * @param name
60
	 *            the name of the argument
55
	 *            the name of the argument
61
	 * @param value
56
	 * @param value
62
	 *            the value of the argument
57
	 *            the value of the argument
63
	 */
58
	 */
64
	public void addArgument(String name, String value) {
59
	public void addArgument(String name, String value, String opcode) {
65
		addArgument(new Argument(name, value, null));
60
		addArgument(new LDAPArgument(name, value, opcode, null));
66
	}
61
	}
67
	/**
62
	/**
68
	 * Add a new argument.
63
	 * Add a new argument.
69
	 * 
64
	 * 
70
	 * @param arg
65
	 * @param arg
71
	 *            the new argument
66
	 *            the new argument
72
	 */
67
	 */
73
	public void addArgument(Argument arg) {
68
	public void addArgument(LDAPArgument arg) {
74
		TestElementProperty newArg = new TestElementProperty(arg.getName(), arg);
69
		TestElementProperty newArg = new TestElementProperty(arg.getName(), arg);
75
		if (isRunningVersion()) {
70
		if (isRunningVersion()) {
76
			this.setTemporary(newArg);
71
			this.setTemporary(newArg);
77
		}
72
		}
78
		getArguments().addItem(newArg);
73
		getArguments().addItem(newArg);
79
	}
74
	}
80
	/**
75
	/**
81
	 * Add a new argument with the given name, value, and metadata.
76
	 * Add a new argument with the given name, value, and metadata.
82
	 * 
77
	 * 
83
	 * @param name
78
	 * @param name
84
	 *            the name of the argument
79
	 *            the name of the argument
85
	 * @param value
80
	 * @param value
86
	 *            the value of the argument
81
	 *            the value of the argument
87
	 * @param metadata
82
	 * @param metadata
88
	 *            the metadata for the argument
83
	 *            the metadata for the argument
89
	 */
84
	 */
90
	public void addArgument(String name, String value, String metadata) {
85
	public void addArgument(String name, String value, String opcode, String metadata) {
91
		addArgument(new Argument(name, value, metadata));
86
		addArgument(new LDAPArgument(name, value, opcode, metadata));
92
	}
87
	}
93
	/**
88
	/**
94
	 * Get a PropertyIterator of the arguments.
89
	 * Get a PropertyIterator of the arguments.
95
	 * 
90
	 * 
96
	 * @return an iteration of the arguments
91
	 * @return an iteration of the arguments
97
	 */
92
	 */
98
	public PropertyIterator iterator() {
93
	public PropertyIterator iterator() {
99
		return getArguments().iterator();
94
		return getArguments().iterator();
100
	}
95
	}
101
	/**
96
	/**
102
	 * Create a string representation of the arguments.
97
	 * Create a string representation of the arguments.
103
	 * 
98
	 * 
104
	 * @return the string representation of the arguments
99
	 * @return the string representation of the arguments
105
	 */
100
	 */
106
	public String toString() {
101
	public String toString() {
107
		StringBuffer str = new StringBuffer();
102
		StringBuffer str = new StringBuffer();
108
		PropertyIterator iter = getArguments().iterator();
103
		PropertyIterator iter = getArguments().iterator();
109
		while (iter.hasNext()) {
104
		while (iter.hasNext()) {
110
			Argument arg = (Argument) iter.next().getObjectValue();
105
			LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
111
			final String metaData = arg.getMetaData();
106
			final String metaData = arg.getMetaData();
112
			str.append(arg.getName());
107
			str.append(arg.getName());
113
			if (metaData == null) {
108
			if (metaData == null) {
114
				str.append("="); //$NON-NLS-1$
109
				str.append("=");  //$NON-NLS$
115
			} else {
110
			} else {
116
				str.append(metaData);
111
				str.append(metaData);
117
			}
112
			}
118
			str.append(arg.getValue());
113
			str.append(arg.getValue());
119
			if (iter.hasNext()) {
114
			if (iter.hasNext()) {
120
				str.append("&"); //$NON-NLS-1$
115
				str.append("&"); //$NON-NLS$
121
			}
116
			}
122
		}
117
		}
123
		return str.toString();
118
		return str.toString();
124
	}
119
	}
125
	/**
120
	/**
126
	 * Remove the specified argument from the list.
121
	 * Remove the specified argument from the list.
127
	 * 
122
	 * 
128
	 * @param row
123
	 * @param row
129
	 *            the index of the argument to remove
124
	 *            the index of the argument to remove
130
	 */
125
	 */
131
	public void removeArgument(int row) {
126
	public void removeArgument(int row) {
132
		if (row < getArguments().size()) {
127
		if (row < getArguments().size()) {
133
			getArguments().remove(row);
128
			getArguments().remove(row);
134
		}
129
		}
135
	}
130
	}
136
	/**
131
	/**
137
	 * Remove the specified argument from the list.
132
	 * Remove the specified argument from the list.
138
	 * 
133
	 * 
139
	 * @param arg
134
	 * @param arg
140
	 *            the argument to remove
135
	 *            the argument to remove
141
	 */
136
	 */
142
	public void removeArgument(Argument arg) {
137
	public void removeArgument(LDAPArgument arg) {
143
		PropertyIterator iter = getArguments().iterator();
138
		PropertyIterator iter = getArguments().iterator();
144
		while (iter.hasNext()) {
139
		while (iter.hasNext()) {
145
			Argument item = (Argument) iter.next().getObjectValue();
140
			LDAPArgument item = (LDAPArgument) iter.next().getObjectValue();
146
			if (arg.equals(item)) {
141
			if (arg.equals(item)) {
147
				iter.remove();
142
				iter.remove();
148
			}
143
			}
149
		}
144
		}
150
	}
145
	}
151
	/**
146
	/**
152
	 * Remove the argument with the specified name.
147
	 * Remove the argument with the specified name.
153
	 * 
148
	 * 
154
	 * @param argName
149
	 * @param argName
155
	 *            the name of the argument to remove
150
	 *            the name of the argument to remove
156
	 */
151
	 */
157
	public void removeArgument(String argName) {
152
	public void removeArgument(String argName) {
158
		PropertyIterator iter = getArguments().iterator();
153
		PropertyIterator iter = getArguments().iterator();
159
		while (iter.hasNext()) {
154
		while (iter.hasNext()) {
160
			Argument arg = (Argument) iter.next().getObjectValue();
155
			LDAPArgument arg = (LDAPArgument) iter.next().getObjectValue();
161
			if (arg.getName().equals(argName)) {
156
			if (arg.getName().equals(argName)) {
162
				iter.remove();
157
				iter.remove();
163
			}
158
			}
164
		}
159
		}
165
	}
160
	}
166
	/**
161
	/**
167
	 * Remove all arguments from the list.
162
	 * Remove all arguments from the list.
168
	 */
163
	 */
169
	public void removeAllArguments() {
164
	public void removeAllArguments() {
170
		getArguments().clear();
165
		getArguments().clear();
171
	}
166
	}
172
	/**
167
	/**
173
	 * Add a new empty argument to the list. The new argument will have the
168
	 * Add a new empty argument to the list. The new argument will have the
174
	 * empty string as its name and value, and null metadata.
169
	 * empty string as its name and value, and null metadata.
175
	 */
170
	 */
176
	public void addEmptyArgument() {
171
	public void addEmptyArgument() {
177
		addArgument(new Argument("", "", null));
172
		addArgument(new LDAPArgument("", "", "", null));
178
	}
173
	}
179
	/**
174
	/**
180
	 * Get the number of arguments in the list.
175
	 * Get the number of arguments in the list.
181
	 * 
176
	 * 
182
	 * @return the number of arguments
177
	 * @return the number of arguments
183
	 */
178
	 */
184
	public int getArgumentCount() {
179
	public int getArgumentCount() {
185
		return getArguments().size();
180
		return getArguments().size();
186
	}
181
	}
187
	/**
182
	/**
188
	 * Get a single argument.
183
	 * Get a single argument.
189
	 * 
184
	 * 
190
	 * @param row
185
	 * @param row
191
	 *            the index of the argument to return.
186
	 *            the index of the argument to return.
192
	 * @return the argument at the specified index, or null if no argument
187
	 * @return the argument at the specified index, or null if no argument
193
	 *         exists at that index.
188
	 *         exists at that index.
194
	 */
189
	 */
195
	public Argument getArgument(int row) {
190
	public LDAPArgument getArgument(int row) {
196
		Argument argument = null;
191
		LDAPArgument argument = null;
197
		if (row < getArguments().size()) {
192
		if (row < getArguments().size()) {
198
			argument = (Argument) getArguments().get(row).getObjectValue();
193
			argument = (LDAPArgument) getArguments().get(row).getObjectValue();
199
		}
194
		}
200
		return argument;
195
		return argument;
201
	
196
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0