01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.samplers;
20:
21: import java.util.HashMap;
22: import java.util.LinkedList;
23: import java.util.List;
24: import java.util.Map;
25:
26: import org.apache.jmeter.assertions.Assertion;
27: import org.apache.jmeter.config.ConfigElement;
28:
29: // TODO - not used at present - could perhaps be removed
30: /**
31: * @author Michael Stover
32: */
33: public class Entry {
34:
35: private Map configSet;
36:
37: // Set clonedSet;
38: private Class sampler;
39:
40: private List assertions;
41:
42: public Entry() {
43: configSet = new HashMap();
44: // clonedSet = new HashSet();
45: assertions = new LinkedList();
46: }
47:
48: public void addAssertion(Assertion assertion) {
49: assertions.add(assertion);
50: }
51:
52: public List getAssertions() {
53: return assertions;
54: }
55:
56: public void setSamplerClass(Class samplerClass) {
57: this .sampler = samplerClass;
58: }
59:
60: public Class getSamplerClass() {
61: return this .sampler;
62: }
63:
64: public ConfigElement getConfigElement(Class configClass) {
65: return (ConfigElement) configSet.get(configClass);
66: }
67:
68: public void addConfigElement(ConfigElement config) {
69: addConfigElement(config, config.getClass());
70: }
71:
72: /**
73: * Add a config element as a specific class. Usually this is done to add a
74: * subclass as one of it's parent classes.
75: */
76: public void addConfigElement(ConfigElement config, Class asClass) {
77: if (config != null) {
78: ConfigElement current = (ConfigElement) configSet
79: .get(asClass);
80: if (current == null) {
81: configSet.put(asClass, cloneIfNecessary(config));
82: } else {
83: current.addConfigElement(config);
84: }
85: }
86: }
87:
88: private ConfigElement cloneIfNecessary(ConfigElement config) {
89: if (config.expectsModification()) {
90: return config;
91: }
92: return (ConfigElement) config.clone();
93: }
94: }
|