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 LongProperty extends NumberProperty {
027: long value;
028:
029: long savedValue;
030:
031: public LongProperty(String name, long value) {
032: super (name);
033: this .value = value;
034: }
035:
036: public LongProperty() {
037: super ();
038: }
039:
040: /*
041: * (non-Javadoc)
042: *
043: * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
044: */
045: public void setRunningVersion(boolean runningVersion) {
046: savedValue = value;
047: super .setRunningVersion(runningVersion);
048: }
049:
050: /*
051: * (non-Javadoc)
052: *
053: * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
054: */
055: public void recoverRunningVersion(TestElement owner) {
056: value = savedValue;
057: }
058:
059: public void setValue(int value) {
060: this .value = value;
061: }
062:
063: protected void setNumberValue(Number n) {
064: value = n.longValue();
065: }
066:
067: protected void setNumberValue(String n)
068: throws NumberFormatException {
069: value = Long.parseLong(n);
070: }
071:
072: /**
073: * @see JMeterProperty#getStringValue()
074: */
075: public String getStringValue() {
076: return Long.toString(value);
077: }
078:
079: /**
080: * @see JMeterProperty#getObjectValue()
081: */
082: public Object getObjectValue() {
083: return new Long(value);
084: }
085:
086: public Object clone() {
087: LongProperty prop = (LongProperty) super .clone();
088: prop.value = value;
089: return prop;
090: }
091:
092: /**
093: * @see JMeterProperty#getBooleanValue()
094: */
095: public boolean getBooleanValue() {
096: return getLongValue() > 0 ? true : false;
097: }
098:
099: /**
100: * @see JMeterProperty#getDoubleValue()
101: */
102: public double getDoubleValue() {
103: return value;
104: }
105:
106: /**
107: * @see JMeterProperty#getFloatValue()
108: */
109: public float getFloatValue() {
110: return value;
111: }
112:
113: /**
114: * @see JMeterProperty#getIntValue()
115: */
116: public int getIntValue() {
117: return (int) value;
118: }
119:
120: /**
121: * @see JMeterProperty#getLongValue()
122: */
123: public long getLongValue() {
124: return value;
125: }
126: }
|