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;
}
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);
}
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);
}
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
}
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());
}
Aggregations