| 15 | |
| 16 | |
| 17 | final class IonIntLite |
| 18 | extends IonValueLite |
| 19 | implements IonInt |
| 20 | { |
| 21 | static private final BigInteger LONG_MIN_VALUE = |
| 22 | BigInteger.valueOf(Long.MIN_VALUE); |
| 23 | |
| 24 | static private final BigInteger LONG_MAX_VALUE = |
| 25 | BigInteger.valueOf(Long.MAX_VALUE); |
| 26 | |
| 27 | private static final int HASH_SIGNATURE = |
| 28 | IonType.INT.toString().hashCode(); |
| 29 | |
| 30 | |
| 31 | // This mask combines the IS_BOOL_TRUE (0x08) and IS_IVM (0x10) |
| 32 | // masks from IonValueLite. Those flags are never relevant for |
| 33 | // IonInts, which makes them safe for reuse here. |
| 34 | private static final int INT_SIZE_MASK = 0x18; |
| 35 | private static final int INT_SIZE_SHIFT = 0x03; |
| 36 | |
| 37 | private static final IntegerSize[] SIZES = IntegerSize.values(); |
| 38 | |
| 39 | private long _long_value; |
| 40 | private BigInteger _big_int_value; |
| 41 | |
| 42 | /** |
| 43 | * Constructs a <code>null.int</code> element. |
| 44 | */ |
| 45 | IonIntLite(ContainerlessContext context, boolean isNull) |
| 46 | { |
| 47 | super(context, isNull); |
| 48 | } |
| 49 | |
| 50 | IonIntLite(IonIntLite existing, IonContext context) |
| 51 | { |
| 52 | super(existing, context); |
| 53 | this._long_value = existing._long_value; |
| 54 | this._big_int_value = existing._big_int_value; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | IonValueLite shallowClone(IonContext context) |
| 59 | { |
| 60 | return new IonIntLite(this, context); |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public IonIntLite clone() |
| 65 | { |
| 66 | return (IonIntLite) shallowClone(ContainerlessContext.wrap(getSystem())); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | int hashSignature() { |
| 71 | return HASH_SIGNATURE; |
| 72 | } |
| 73 | |
| 74 | @Override |