KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > samplers > Entry


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/Entry.java,v 1.7 2004/02/13 02:21:38 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
22 //import java.util.HashSet;
23
import java.util.LinkedList JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26 //import java.util.Set;
27

28 import org.apache.jmeter.assertions.Assertion;
29 import org.apache.jmeter.config.ConfigElement;
30 import org.apache.jorphan.logging.LoggingManager;
31 import org.apache.log.Logger;
32
33 /**
34  * @author Michael Stover
35  * @version $Revision: 1.7 $
36  */

37 public class Entry
38 {
39     transient private static Logger log = LoggingManager.getLoggerForClass();
40     Map JavaDoc configSet;
41     //Set clonedSet;
42
Class JavaDoc sampler;
43     List JavaDoc assertions;
44
45     public Entry()
46     {
47         configSet = new HashMap JavaDoc();
48         //clonedSet = new HashSet();
49
assertions = new LinkedList JavaDoc();
50     }
51
52     public void addAssertion(Assertion assertion)
53     {
54         assertions.add(assertion);
55     }
56
57     public List JavaDoc getAssertions()
58     {
59         return assertions;
60     }
61
62     public void setSamplerClass(Class JavaDoc samplerClass)
63     {
64         this.sampler = samplerClass;
65     }
66
67     public Class JavaDoc getSamplerClass()
68     {
69         return this.sampler;
70     }
71
72     public ConfigElement getConfigElement(Class JavaDoc configClass)
73     {
74         return (ConfigElement) configSet.get(configClass);
75     }
76
77     public void addConfigElement(ConfigElement config)
78     {
79         addConfigElement(config, config.getClass());
80     }
81
82     /**
83      * Add a config element as a specific class. Usually this is done to add a
84      * subclass as one of it's parent classes.
85      */

86     public void addConfigElement(ConfigElement config, Class JavaDoc asClass)
87     {
88         if (config != null)
89         {
90             ConfigElement current = (ConfigElement) configSet.get(asClass);
91             if (current == null)
92             {
93                 configSet.put(asClass, cloneIfNecessary(config));
94             }
95             else
96             {
97                 current.addConfigElement(config);
98             }
99         }
100     }
101
102     private ConfigElement cloneIfNecessary(ConfigElement config)
103     {
104         if (config.expectsModification())
105         {
106             return config;
107         }
108         else
109         {
110             return (ConfigElement) config.clone();
111         }
112     }
113
114     public Object JavaDoc clone()
115     {
116         try
117         {
118             return super.clone();
119         }
120         catch (Exception JavaDoc ex)
121         {
122             log.error("", ex);
123         }
124         return null;
125     }
126 }
127
Popular Tags