示例#1
0
  @Test
  public void testBinaryDecimals() throws Exception {
    IonDatagram dg = loadTestFile("good/decimalOneDotZero.10n");
    assertEquals(1, dg.size());

    IonDecimal value = (IonDecimal) dg.get(0);
    BigDecimal dec = value.bigDecimalValue();
    checkDecimal(10, 1, dec);
    assertEquals(1, dec.intValue());

    dg = loadTestFile("good/decimalNegativeOneDotZero.10n");
    assertEquals(1, dg.size());

    value = (IonDecimal) dg.get(0);
    dec = value.bigDecimalValue();
    checkDecimal(-10, 1, dec);
    assertEquals(-1, dec.intValue());
  }
 void re_init(IonValue value, boolean hoisted) {
   _symbols = null;
   _curr = null;
   _eof = false;
   _top = 0;
   _hoisted = hoisted;
   if (value instanceof IonDatagram) {
     // datagrams interacting with these readers must be
     // IonContainerPrivate containers
     assert (value instanceof PrivateIonContainer);
     IonDatagram dg = (IonDatagram) value;
     _parent = dg;
     _next = null;
     _iter = dg.systemIterator(); // we want a system reader not: new Children(dg);
   } else {
     _parent = (hoisted ? null : value.getContainer());
     _next = (PrivateIonValue) value;
   }
 }