001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.testelement.property;
020:
021: import org.apache.jmeter.testelement.TestElement;
022:
023: /**
024: * @version $Revision: 571988 $
025: */
026: public class IntegerProperty extends NumberProperty {
027: int value;
028:
029: int savedValue;
030:
031: public IntegerProperty(String name, int value) {
032: super (name);
033: this .value = value;
034: }
035:
036: /*
037: * (non-Javadoc)
038: *
039: * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
040: */
041: public void setRunningVersion(boolean runningVersion) {
042: savedValue = value;
043: super .setRunningVersion(runningVersion);
044: }
045:
046: /*
047: * (non-Javadoc)
048: *
049: * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
050: */
051: public void recoverRunningVersion(TestElement owner) {
052: value = savedValue;
053: }
054:
055: public IntegerProperty(String name) {
056: super (name);
057: }
058:
059: public IntegerProperty() {
060: super ();
061: }
062:
063: public void setValue(int value) {
064: this .value = value;
065: }
066:
067: protected void setNumberValue(Number n) {
068: value = n.intValue();
069: }
070:
071: protected void setNumberValue(String n)
072: throws NumberFormatException {
073: value = Integer.parseInt(n);
074: }
075:
076: /**
077: * @see JMeterProperty#getStringValue()
078: */
079: public String getStringValue() {
080: return Integer.toString(value);
081: }
082:
083: /**
084: * @see JMeterProperty#getObjectValue()
085: */
086: public Object getObjectValue() {
087: return new Integer(value);
088: }
089:
090: public Object clone() {
091: IntegerProperty prop = (IntegerProperty) super .clone();
092: prop.value = value;
093: return prop;
094: }
095:
096: /**
097: * @see JMeterProperty#getBooleanValue()
098: */
099: public boolean getBooleanValue() {
100: return getIntValue() > 0 ? true : false;
101: }
102:
103: /**
104: * @see JMeterProperty#getDoubleValue()
105: */
106: public double getDoubleValue() {
107: return value;
108: }
109:
110: /**
111: * @see JMeterProperty#getFloatValue()
112: */
113: public float getFloatValue() {
114: return value;
115: }
116:
117: /**
118: * @see JMeterProperty#getIntValue()
119: */
120: public int getIntValue() {
121: return value;
122: }
123:
124: /**
125: * @see JMeterProperty#getLongValue()
126: */
127: public long getLongValue() {
128: return value;
129: }
130: }
|