KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > functions > ThreadNumber


1 // $Header: /home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/ThreadNumber.java,v 1.8.2.1 2005/02/18 02:21:37 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.functions;
20
21 import java.io.Serializable JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.LinkedList JavaDoc;
24 import java.util.List JavaDoc;
25
26 import org.apache.jmeter.samplers.SampleResult;
27 import org.apache.jmeter.samplers.Sampler;
28
29 /**
30  * @version $Revision: 1.8.2.1 $
31  */

32 public class ThreadNumber implements Function, Serializable JavaDoc
33 {
34
35     private static final String JavaDoc KEY = "__threadNum";
36     private static final List JavaDoc desc = new LinkedList JavaDoc();
37
38     /* (non-Javadoc)
39      * @see org.apache.jmeter.functions.Function#execute(SampleResult, Sampler)
40      */

41     public String JavaDoc execute(SampleResult previousResult, Sampler currentSampler)
42         throws InvalidVariableException
43     {
44         return Thread.currentThread().getName().substring(
45             Thread.currentThread().getName().lastIndexOf("-") + 1);
46     }
47
48     /* (non-Javadoc)
49      * @see org.apache.jmeter.functions.Function#setParameters(Collection)
50      */

51     public void setParameters(Collection JavaDoc parameters)
52         throws InvalidVariableException
53     {
54     }
55
56     /* (non-Javadoc)
57      * @see org.apache.jmeter.functions.Function#getReferenceKey()
58      */

59     public String JavaDoc getReferenceKey()
60     {
61         return KEY;
62     }
63
64     /* (non-Javadoc)
65      * @see org.apache.jmeter.functions.Function#getArgumentDesc()
66      */

67     public List JavaDoc getArgumentDesc()
68     {
69         return desc;
70     }
71 }
72
Popular Tags