KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > threads > JMeterContext


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/JMeterContext.java,v 1.11 2004/02/14 03:34:29 sebb Exp $
2
/*
3  * Copyright 2000-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.threads;
20
21 import org.apache.jmeter.samplers.SampleResult;
22 import org.apache.jmeter.samplers.Sampler;
23
24 /**
25  * @version $Revision: 1.11 $
26  */

27 public class JMeterContext
28 {
29     JMeterVariables variables;
30     SampleResult previousResult;
31     Sampler currentSampler;
32     Sampler previousSampler;
33     boolean samplingStarted;
34     private int threadNum;
35     private byte[] readBuffer = null;
36
37     JMeterContext()
38     {
39         variables = null;
40         previousResult = null;
41         currentSampler = null;
42         samplingStarted = false;
43     }
44     
45     public void clear()
46     {
47         variables = null;
48         previousResult = null;
49         currentSampler = null;
50         previousSampler = null;
51         samplingStarted = false;
52         threadNum = 0;
53         readBuffer = null;
54     }
55
56     public JMeterVariables getVariables()
57     {
58         return variables;
59     }
60     
61     public byte[] getReadBuffer()
62     {
63         if(readBuffer == null)
64         {
65             readBuffer = new byte[8192];
66         }
67         return readBuffer;
68     }
69
70     public void setVariables(JMeterVariables vars)
71     {
72         this.variables = vars;
73     }
74
75     public SampleResult getPreviousResult()
76     {
77         return previousResult;
78     }
79
80     public void setPreviousResult(SampleResult result)
81     {
82         this.previousResult = result;
83     }
84
85     public Sampler getCurrentSampler()
86     {
87         return currentSampler;
88     }
89
90     public void setCurrentSampler(Sampler sampler)
91     {
92         setPreviousSampler(currentSampler);
93         this.currentSampler = sampler;
94     }
95
96     /**
97      * Returns the previousSampler.
98      * @return Sampler
99      */

100     public Sampler getPreviousSampler()
101     {
102         return previousSampler;
103     }
104
105     /**
106      * Sets the previousSampler.
107      * @param previousSampler the previousSampler to set
108      */

109     public void setPreviousSampler(Sampler previousSampler)
110     {
111         this.previousSampler = previousSampler;
112     }
113
114     /**
115      * Returns the threadNum.
116      * @return int
117      */

118     public int getThreadNum()
119     {
120         return threadNum;
121     }
122
123     /**
124      * Sets the threadNum.
125      * @param threadNum the threadNum to set
126      */

127     public void setThreadNum(int threadNum)
128     {
129         this.threadNum = threadNum;
130     }
131
132     public boolean isSamplingStarted()
133     {
134         return samplingStarted;
135     }
136
137     public void setSamplingStarted(boolean b)
138     {
139         samplingStarted = b;
140     }
141 }
142
Popular Tags