| 13 | |
| 14 | |
| 15 | final class IonFloatLite |
| 16 | extends IonValueLite |
| 17 | implements IonFloat |
| 18 | { |
| 19 | private static final int HASH_SIGNATURE = |
| 20 | IonType.FLOAT.toString().hashCode(); |
| 21 | |
| 22 | private Double _float_value; |
| 23 | |
| 24 | /** |
| 25 | * Constructs a <code>null.float</code> element. |
| 26 | */ |
| 27 | IonFloatLite(ContainerlessContext context, boolean isNull) |
| 28 | { |
| 29 | super(context, isNull); |
| 30 | } |
| 31 | |
| 32 | IonFloatLite(IonFloatLite existing, IonContext context) |
| 33 | { |
| 34 | super(existing, context); |
| 35 | // shallow copy as Double is immutable |
| 36 | this._float_value = existing._float_value; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | IonValueLite shallowClone(IonContext context) |
| 41 | { |
| 42 | return new IonFloatLite(this, context); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public IonFloatLite clone() |
| 47 | { |
| 48 | return (IonFloatLite) shallowClone(ContainerlessContext.wrap(getSystem())); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | int hashSignature() { |
| 53 | return HASH_SIGNATURE; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | int scalarHashCode() |
| 58 | { |
| 59 | int result = HASH_SIGNATURE; |
| 60 | long bits = Double.doubleToLongBits(_float_value); |
| 61 | result ^= (int) ((bits >>> 32) ^ bits); |
| 62 | return hashTypeAnnotations(result); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public IonType getTypeSlow() |
| 67 | { |
| 68 | return IonType.FLOAT; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | public float floatValue() |