MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / IonLoaderLite

Class IonLoaderLite

src/main/java/com/amazon/ion/impl/lite/IonLoaderLite.java:36–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36final class IonLoaderLite
37 implements IonLoader
38{
39 private final IonSystemLite _system;
40
41 /** Not null. */
42 private final IonCatalog _catalog;
43
44 private final IonReaderBuilder _readerBuilder;
45
46 /**
47 * @param system must not be null.
48 * @param catalog must not be null.
49 */
50 public IonLoaderLite(IonSystemLite system, IonCatalog catalog)
51 {
52 assert system != null;
53 assert catalog != null;
54
55 _system = system;
56 _catalog = catalog;
57 if (catalog == system.getCatalog()) {
58 _readerBuilder = system.getReaderBuilder();
59 } else {
60 // The IonCatalog provided in the constructor always takes precedence over the one already configured on the
61 // system's IonReaderBuilder.
62 _readerBuilder = system.getReaderBuilder().withCatalog(catalog).immutable();
63 }
64 }
65
66 public IonSystem getSystem()
67 {
68 return _system;
69 }
70
71 public IonCatalog getCatalog()
72 {
73 return _catalog;
74 }
75
76
77 /**
78 * This doesn't wrap IOException because some callers need to propagate it.
79 *
80 * @return a new datagram; not null.
81 */
82 private IonDatagramLite load_helper(IonReader reader)
83 throws IOException
84 {
85 IonDatagramLite datagram = new IonDatagramLite(_system, _catalog);
86 IonWriter writer = _Private_IonWriterFactory.makeWriter(datagram);
87 writer.writeValues(reader);
88 if (_readerBuilder.isIncrementalReadingEnabled() && reader instanceof IonCursor) {
89 // Force incremental readers to either disambiguate an incomplete value or raise an error.
90 if (((IonCursor) reader).endStream() != IonCursor.Event.NEEDS_DATA) {
91 // Only text readers can reach this case, because it indicates that completion of an ambiguous token
92 // was forced. Add the resulting value to the datagram.
93 writer.writeValue(reader);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…