1 18 19 22 package org.apache.jmeter.testelement.property; 23 24 28 public abstract class NumberProperty extends AbstractProperty 29 { 30 public NumberProperty() 31 { 32 super(); 33 } 34 35 public NumberProperty(String name) 36 { 37 super(name); 38 } 39 40 43 protected abstract void setNumberValue(Number n); 44 45 48 protected abstract void setNumberValue(String n) 49 throws NumberFormatException ; 50 51 public void setObjectValue(Object v) 52 { 53 if (v instanceof Number ) 54 { 55 setNumberValue((Number ) v); 56 } 57 else 58 { 59 try 60 { 61 setNumberValue(v.toString()); 62 } 63 catch (RuntimeException e) 64 { 65 } 66 } 67 } 68 69 72 public int compareTo(Object arg0) 73 { 74 if(arg0 instanceof JMeterProperty) 75 { 76 double compareValue = 77 getDoubleValue() - ((JMeterProperty) arg0).getDoubleValue(); 78 79 if(compareValue < 0) 80 { 81 return -1; 82 } 83 else if(compareValue == 0) 84 { 85 return 0; 86 } 87 else 88 { 89 return 1; 90 } 91 } 92 else 93 { 94 return -1; 95 } 96 } 97 } 98 | Popular Tags |