1 43 44 package org.exolab.jms.selector; 45 46 47 54 final class SDouble extends SNumber { 55 56 59 private final double _value; 60 61 64 public SDouble() { 65 _value = 0; 66 } 67 68 73 public SDouble(final double value) { 74 _value = value; 75 } 76 77 83 public SNumber add(final SNumber number) { 84 return new SDouble(_value + number.getDouble()); 85 } 86 87 93 public SNumber subtract(final SNumber number) { 94 return new SDouble(_value - number.getDouble()); 95 } 96 97 103 public SNumber multiply(final SNumber number) { 104 return new SDouble(_value * number.getDouble()); 105 } 106 107 113 public SNumber divide(final SNumber number) { 114 SNumber result = null; 115 try { 116 result = new SDouble(_value / number.getDouble()); 117 } catch (ArithmeticException ignore) { 118 } 119 return result; 120 } 121 122 127 public long getLong() { 128 return (long) _value; 129 } 130 131 136 public double getDouble() { 137 return _value; 138 } 139 140 145 public Object getObject() { 146 return new Double (_value); 147 } 148 149 156 public SBool equal(final SObject obj) { 157 SBool result = SBool.FALSE; 158 double rhs = ((SNumber) obj).getDouble(); 159 if (_value == rhs) { 160 result = SBool.TRUE; 161 } 162 return result; 163 } 164 165 172 public SBool less(final SObject obj) { 173 SBool result = SBool.FALSE; 174 double rhs = ((SNumber) obj).getDouble(); 175 if (_value < rhs) { 176 result = SBool.TRUE; 177 } 178 return result; 179 } 180 181 188 public SBool greater(final SObject obj) { 189 SBool result = SBool.FALSE; 190 double rhs = ((SNumber) obj).getDouble(); 191 if (_value > rhs) { 192 result = SBool.TRUE; 193 } 194 return result; 195 } 196 197 } | Popular Tags |