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.timers;
20:
21: import java.beans.PropertyDescriptor;
22: import java.util.ResourceBundle;
23:
24: import org.apache.jmeter.testbeans.BeanInfoSupport;
25:
26: /**
27: * BeanInfo for the ConstantThroughputTimer.
28: *
29: */
30: public class ConstantThroughputTimerBeanInfo extends BeanInfoSupport {
31: private static final String[] tags = new String[5];
32:
33: public ConstantThroughputTimerBeanInfo() {
34: super (ConstantThroughputTimer.class);
35:
36: ResourceBundle rb = (ResourceBundle) getBeanDescriptor()
37: .getValue(RESOURCE_BUNDLE);
38: // These must agree with the Timer resources
39: tags[0] = rb.getString("calcMode.1"); //$NON-NLS-1$
40: tags[1] = rb.getString("calcMode.2"); //$NON-NLS-1$
41: tags[2] = rb.getString("calcMode.3"); //$NON-NLS-1$
42: tags[3] = rb.getString("calcMode.4"); //$NON-NLS-1$
43: tags[4] = rb.getString("calcMode.5"); //$NON-NLS-1$
44: createPropertyGroup("delay", //$NON-NLS-1$
45: new String[] { "throughput", //$NON-NLS-1$
46: "calcMode" }); //$NON-NLS-1$
47:
48: PropertyDescriptor p = property("throughput"); //$NON-NLS-1$
49: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
50: p.setValue(DEFAULT, new Double(0.0));
51:
52: p = property("calcMode"); //$NON-NLS-1$
53: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
54: p.setValue(DEFAULT, tags[0]);
55: p.setValue(NOT_OTHER, Boolean.TRUE);
56: p.setValue(NOT_EXPRESSION, Boolean.TRUE);
57: p.setValue(TAGS, tags);
58: }
59:
60: // TODO need to find better way to do this
61: public static int getCalcModeAsInt(String mode) {
62: for (int i = 0; i < tags.length; i++) {
63: if (tags[i].equals(mode))
64: return i;
65: }
66: return -1;
67: }
68: }
|