use of com.amazon.ion.system.IonTextWriterBuilder in project ion-java by amzn.
the class _Private_CommandLine method doPrintVersion.
private static void doPrintVersion() throws IOException {
IonTextWriterBuilder b = IonTextWriterBuilder.pretty();
b.setCharset(IonTextWriterBuilder.ASCII);
IonWriter w = b.build((Appendable) System.out);
w.stepIn(IonType.STRUCT);
{
w.setFieldName("version");
w.writeString(info.getProjectVersion());
w.setFieldName("build_time");
w.writeTimestamp(info.getBuildTime());
}
w.stepOut();
w.finish();
System.out.println();
}
use of com.amazon.ion.system.IonTextWriterBuilder in project ion-java by amzn.
the class RoundTripTest method testStandardTextWriter.
@Test
public void testStandardTextWriter() throws Exception {
IonTextWriterBuilder b = IonTextWriterBuilder.standard();
checkTextOutput(b);
}
use of com.amazon.ion.system.IonTextWriterBuilder in project ion-java by amzn.
the class TextWriterTest method testNewLineTypesWithPrettyPrinting.
@Test
public void testNewLineTypesWithPrettyPrinting() {
for (IonTextWriterBuilder.NewLineType nlt : IonTextWriterBuilder.NewLineType.values()) {
String expected = String.format("%s\"Foo\"%<sBar%<s(%<s 1%<s 2%<s 3%<s)%<s[%<s 4,%<s 5,%<s 6%<s]", nlt.getCharSequence());
IonTextWriterBuilder writerBuilder = IonTextWriterBuilder.standard().withInitialIvmHandling(SUPPRESS).withWriteTopLevelValuesOnNewLines(false).withPrettyPrinting().withNewLineType(nlt);
IonDatagram dg = system().newDatagram();
dg.add().newString("Foo");
dg.add().newSymbol("Bar");
dg.add().newSexp(new int[] { 1, 2, 3 });
dg.add().newList(new int[] { 4, 5, 6 });
StringBuilder sb = new StringBuilder();
IonWriter writer = writerBuilder.build(sb);
dg.writeTo(writer);
assertEquals(expected, sb.toString());
}
}
Aggregations