use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class OptimizedBinaryWriterSymbolTableTest method testOptimizedWriteValueSubsetWriterLST2.
/**
* Writer's LST subset of Reader's - no optimize.
* Reader's symtab has a gap at the end.
*/
@Test
public void testOptimizedWriteValueSubsetWriterLST2() throws Exception {
// Create reader with LST with a gap at the end
String readerLST = printLocalSymtab("amazon", "website", null);
byte[] source = encode(readerLST + "amazon website");
ir = makeReaderProxy(source);
iw = makeWriterWithLocalSymtab("amazon", "website");
// amazon
checkWriteValueWithIncompatibleSymtab();
// website
checkWriteValueWithIncompatibleSymtab();
iw.close();
IonDatagram expected = loader().load("amazon website");
IonDatagram actual = loader().load(outputByteArray());
assertIonEquals(expected, actual);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class OptimizedBinaryWriterSymbolTableTest method testOptimizedWriteValueSupersetWriterLST1.
/**
* Writer's LST superset of Reader's - optimize.
*/
@Test
public void testOptimizedWriteValueSupersetWriterLST1() throws Exception {
String readerLST = printLocalSymtab("amazon");
byte[] source = encode(readerLST + "amazon");
ir = makeReaderProxy(source);
iw = makeWriterWithLocalSymtab("amazon", "website");
// amazon
checkWriteValueWithCompatibleSymtab();
iw.close();
IonDatagram expected = loader().load("amazon");
IonDatagram actual = loader().load(outputByteArray());
assertIonEquals(expected, actual);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class OptimizedBinaryWriterSymbolTableTest method testOptimizedWriteValueSupersetWriterLST2.
/**
* Writer's LST superset of Reader's - optimize.
* Writer's symtab has a gap at the end.
*/
@Test
public void testOptimizedWriteValueSupersetWriterLST2() throws Exception {
String readerLST = printLocalSymtab("amazon", "website");
byte[] source = encode(readerLST + "amazon website");
ir = makeReaderProxy(source);
iw = makeWriterWithLocalSymtab("amazon", "website", null);
// amazon
checkWriteValueWithCompatibleSymtab();
// website
checkWriteValueWithCompatibleSymtab();
iw.close();
IonDatagram expected = loader().load("amazon website");
IonDatagram actual = loader().load(outputByteArray());
assertIonEquals(expected, actual);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class OptimizedBinaryWriterSymbolTableTest method testOptimizedWriteValueSubsetWriterLST1.
/**
* Writer's LST subset of Reader's - no optimize.
*/
@Test
public void testOptimizedWriteValueSubsetWriterLST1() throws Exception {
String readerLST = printLocalSymtab("amazon", "website");
byte[] source = encode(readerLST + "amazon website");
ir = makeReaderProxy(source);
iw = makeWriterWithLocalSymtab("amazon");
// amazon
checkWriteValueWithIncompatibleSymtab();
// website
checkWriteValueWithIncompatibleSymtab();
iw.close();
IonDatagram expected = loader().load("amazon website");
IonDatagram actual = loader().load(outputByteArray());
assertIonEquals(expected, actual);
}
use of com.amazon.ion.IonDatagram in project ion-java by amzn.
the class IonSystemLite method clone.
@SuppressWarnings("unchecked")
public <T extends IonValue> T clone(T value) throws IonException {
// Use "fast clone" when the system is the same.
if (value.getSystem() == this) {
return (T) value.clone();
}
if (value instanceof IonDatagram) {
IonDatagram datagram = newDatagram();
IonWriter writer = _Private_IonWriterFactory.makeWriter(datagram);
IonReader reader = makeSystemReader(value.getSystem(), value);
try {
writer.writeValues(reader);
} catch (IOException e) {
throw new IonException(e);
}
return (T) datagram;
}
IonReader reader = newReader(value);
reader.next();
return (T) newValue(reader);
}
Aggregations