Search in sources :

Example 6 with IonString

use of com.amazon.ion.IonString in project ion-java by amzn.

the class _Private_CurriedValueFactory method newNullString.

// -------------------------------------------------------------------------
public IonString newNullString() {
    IonString v = myFactory.newNullString();
    handle(v);
    return v;
}
Also used : IonString(com.amazon.ion.IonString)

Example 7 with IonString

use of com.amazon.ion.IonString in project ion-java by amzn.

the class IonWriterTestCase method testWritingNonAscii.

@Test
public void testWritingNonAscii() throws Exception {
    String text = TestUtils.YEN_SIGN + FERMATA;
    iw = makeWriter();
    iw.writeString(text);
    iw.writeSymbol(text);
    IonDatagram dg = reload();
    IonText t = (IonString) dg.get(0);
    assertEquals(text, t.stringValue());
    t = (IonSymbol) dg.get(1);
    checkSymbol(text, t);
}
Also used : IonText(com.amazon.ion.IonText) IonString(com.amazon.ion.IonString) IonDatagram(com.amazon.ion.IonDatagram) IonString(com.amazon.ion.IonString) Test(org.junit.Test)

Example 8 with IonString

use of com.amazon.ion.IonString in project ion-java by amzn.

the class PrinterTest method testJsonEscapes.

@Test
public void testJsonEscapes() throws Exception {
    String ionEscapes = Q + "\\0\\a\\b\\t\\n\\f\\r\\v\\\"\\'\\?\\\\\\/\\\n" + Q;
    String jsonEscapes = Q + "\\u0000\\u0007\\b\\t\\n\\f\\r\\u000b\\\"'?\\\\/" + Q;
    IonString value = (IonString) system().singleValue(ionEscapes);
    myPrinter.setJsonMode();
    checkRendering(jsonEscapes, value);
}
Also used : IonString(com.amazon.ion.IonString) IonString(com.amazon.ion.IonString) Test(org.junit.Test) IntTest(com.amazon.ion.IntTest) BlobTest(com.amazon.ion.BlobTest) ClobTest(com.amazon.ion.ClobTest)

Example 9 with IonString

use of com.amazon.ion.IonString in project ion-java by amzn.

the class PrinterTest method testPrintingString.

@Test
public void testPrintingString() throws Exception {
    IonString value = system().newNullString();
    checkNullRendering("null.string", value);
    value.setValue("Adam E");
    checkRendering("\"Adam E\"", value);
    value.setValue("Oh, \"Hello!\"");
    checkRendering("\"Oh, \\\"Hello!\\\"\"", value);
    value.addTypeAnnotation("an");
    checkRendering("an::\"Oh, \\\"Hello!\\\"\"", value);
    value = system().newString("Ab\u0000");
    checkRendering("\"Ab\\0\"", value);
    myPrinter.setPrintStringAsJson(true);
    checkRendering("\"Ab\\u0000\"", value);
// TODO check escaping
}
Also used : IonString(com.amazon.ion.IonString) Test(org.junit.Test) IntTest(com.amazon.ion.IntTest) BlobTest(com.amazon.ion.BlobTest) ClobTest(com.amazon.ion.ClobTest)

Example 10 with IonString

use of com.amazon.ion.IonString in project ion-java by amzn.

the class IonReaderBinaryIncrementalTest method incrementalMultipleValuesIterate.

private static void incrementalMultipleValuesIterate(Iterator<IonValue> iterator, ResizingPipedInputStream pipe) throws Exception {
    byte[] bytes = toBinary("value_type::\"StringValueLong\"");
    for (byte b : bytes) {
        assertFalse(iterator.hasNext());
        pipe.receive(b);
    }
    assertTrue(iterator.hasNext());
    IonString string = (IonString) iterator.next();
    assertEquals("StringValueLong", string.stringValue());
    assertEquals(Collections.singletonList("value_type"), Arrays.asList(string.getTypeAnnotations()));
    bytes = toBinary("{foobar: \"StringValueLong\"}");
    for (byte b : bytes) {
        assertFalse(iterator.hasNext());
        pipe.receive(b);
    }
    assertTrue(iterator.hasNext());
    IonStruct struct = (IonStruct) iterator.next();
    string = (IonString) struct.get("foobar");
    assertEquals("StringValueLong", string.stringValue());
    assertFalse(iterator.hasNext());
}
Also used : IonStruct(com.amazon.ion.IonStruct) IonString(com.amazon.ion.IonString)

Aggregations

IonString (com.amazon.ion.IonString)13 Test (org.junit.Test)6 IonStruct (com.amazon.ion.IonStruct)5 IonDatagram (com.amazon.ion.IonDatagram)3 BlobTest (com.amazon.ion.BlobTest)2 ClobTest (com.amazon.ion.ClobTest)2 IntTest (com.amazon.ion.IntTest)2 IonInt (com.amazon.ion.IonInt)2 IonList (com.amazon.ion.IonList)2 IonReader (com.amazon.ion.IonReader)2 IonTimestamp (com.amazon.ion.IonTimestamp)2 Date (java.util.Date)2 BinaryTest (com.amazon.ion.BinaryTest)1 IonBlob (com.amazon.ion.IonBlob)1 IonBool (com.amazon.ion.IonBool)1 IonClob (com.amazon.ion.IonClob)1 IonDecimal (com.amazon.ion.IonDecimal)1 IonFloat (com.amazon.ion.IonFloat)1 IonLoader (com.amazon.ion.IonLoader)1 IonNull (com.amazon.ion.IonNull)1