int getIntParameter(String name) throws NumberFormatException { if (params == null || !params.containsKey(name)) { throw new NumberFormatException("No value for parameter named '" + name + "'."); } return Integer.decode((String) params.get(name)).intValue(); } /** * Get the value of a specified parameter as an integer, or return the * specified default value if the value was not specified or is not an * integer. A warning will be logged if the value is not an integer. The * value may be specified in decimal, hexadecimal, or octal, as defined by * Integer.decode(). * * @param name * the name of the parameter whose value should be retrieved * @param defaultValue * the default value to return if the value of this parameter was * not specified * @return the value of the parameter, or the default value if the parameter * was not specified * * @see java.lang.Integer#decode(java.lang.String) */ public int getIntParameter(String name, int defaultValue) { if (params == null || !params.containsKey(name)) { return defaultValue; } try { return Integer.decode((String) params.get(name)).intValue(); } catch (NumberFormatException e) { log.warn("Value for parameter '" + name + "' not an integer: '" + params.get(name) + "'. Using default: '" + defaultValue + "'.", e); return defaultValue; } }
long getLongParameter(String name) throws NumberFormatException { if (params == null || !params.containsKey(name)) { throw new NumberFormatException("No value for parameter named '" + name + "'."); } return Long.decode((String) params.get(name)).longValue(); } /** * Get the value of a specified parameter as along, or return the specified * default value if the value was not specified or is not a long. A warning * will be logged if the value is not a long. The value may be specified in * decimal, hexadecimal, or octal, as defined by Long.decode(). * * @param name * the name of the parameter whose value should be retrieved * @param defaultValue * the default value to return if the value of this parameter was * not specified * @return the value of the parameter, or the default value if the parameter * was not specified * * @see Long#decode(String) */ public long getLongParameter(String name, long defaultValue) { if (params == null || !params.containsKey(name)) { return defaultValue; } try { return Long.decode((String) params.get(name)).longValue(); } catch (NumberFormatException e) { log.warn("Value for parameter '" + name + "' not a long: '" + params.get(name) + "'. Using default: '" + defaultValue + "'.", e); return defaultValue; } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/java/sampler/JavaSamplerContext.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/java/sampler/JavaSamplerContext.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
int getIntParameter(String name) throws NumberFormatException {
1
long getLongParameter(String name) throws NumberFormatException {
2
		if (params == null || !params.containsKey(name)) {
2
		if (params == null || !params.containsKey(name)) {
3
			throw new NumberFormatException("No value for parameter named '" + name + "'.");
3
			throw new NumberFormatException("No value for parameter named '" + name + "'.");
4
		}
4
		}
5
		return Integer.decode((String) params.get(name)).intValue();
5
		return Long.decode((String) params.get(name)).longValue();
6
	}
6
	}
7
	/**
7
	/**
8
	 * Get the value of a specified parameter as an integer, or return the
8
	 * Get the value of a specified parameter as along, or return the
9
	 * specified
9
 specified
10
 default value if the value was not specified or is not an
10
	 * default value if the value was not specified or is not a
11
	 * integer. A warning
11
 long. A warning
12
 will be logged if the value is not an integer. The
12
	 * will be logged if the value is not a
13
	 * value may be specified in
13
 long. The value may be specified in
14
 decimal, hexadecimal, or octal, as defined by
14
	 * decimal, hexadecimal, or octal, as defined by
15
	 * Integer.decode().
15
 Long.decode().
16
	 * 
16
	 * 
17
	 * @param name
17
	 * @param name
18
	 *            the name of the parameter whose value should be retrieved
18
	 *            the name of the parameter whose value should be retrieved
19
	 * @param defaultValue
19
	 * @param defaultValue
20
	 *            the default value to return if the value of this parameter was
20
	 *            the default value to return if the value of this parameter was
21
	 *            not specified
21
	 *            not specified
22
	 * @return the value of the parameter, or the default value if the parameter
22
	 * @return the value of the parameter, or the default value if the parameter
23
	 *         was not specified
23
	 *         was not specified
24
	 * 
24
	 * 
25
	 * @see java.lang.Integer#decode(java.lang.String)
25
	 * @see Long#decode(String)
26
	 */
26
	 */
27
	public int getIntParameter(String name, int defaultValue) {
27
	public long getLongParameter(String name, long defaultValue) {
28
		if (params == null || !params.containsKey(name)) {
28
		if (params == null || !params.containsKey(name)) {
29
			return defaultValue;
29
			return defaultValue;
30
		}
30
		}
31
		try {
31
		try {
32
			return Integer.decode((String) params.get(name)).intValue();
32
			return Long.decode((String) params.get(name)).longValue();
33
		} catch (NumberFormatException e) {
33
		} catch (NumberFormatException e) {
34
			log.warn("Value for parameter '" + name + "' not an integer: '" + params.get(name) + "'.  Using default: '"
34
			log.warn("Value for parameter '" + name + "' not a long: '" + params.get(name) + "'.  Using default: '"
35
					+ defaultValue + "'.", e);
35
					+ defaultValue + "'.", e);
36
			return defaultValue;
36
			return defaultValue;
37
		}
37
		}
38
	}
38
	}
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