use of com.amazon.ion.Span in project ion-java by amzn.
the class RawValueSpanReaderTest method generateSpan.
private SpanTester generateSpan(Object expected, IonType type) {
// This span includes the TID and length bytes
Span span = seekableReader.currentSpan();
// This gets just the value bytes
byte[] expectedBytes = valueBytes((OffsetSpan) spanProvider.valueSpan());
return new SpanTester(expected, type, expectedBytes, span);
}
use of com.amazon.ion.Span in project ion-java by amzn.
the class Spans method currentSpan.
/**
* Attempts to get a {@link Span} facet from the given object, if it
* supports {@link SpanProvider#currentSpan()}.
*
* @param spanProvider may be null.
* @return null if there's not a current span supporting
* {@code spanFacetType}.
*/
public static <T> T currentSpan(Class<T> spanFacetType, Object spanProvider) {
Span span = currentSpan(spanProvider);
T spanFacet = asFacet(spanFacetType, span);
return spanFacet;
}
use of com.amazon.ion.Span in project ion-java by amzn.
the class TextSpanTest method expectNextSpan.
protected void expectNextSpan(int startLine, int startColumn) {
in.next();
Span s = sp.currentSpan();
TextSpan ts = Facets.assumeFacet(TextSpan.class, s);
checkSpan(startLine, startColumn, ts);
ts = currentSpan(TextSpan.class, in);
checkSpan(startLine, startColumn, ts);
}
use of com.amazon.ion.Span in project ion-java by amzn.
the class SeekableReaderTest method testHoistingOrderedStruct.
@Test
public void testHoistingOrderedStruct() throws IOException {
if (getStreamingMode() == StreamingMode.NEW_STREAMING_INCREMENTAL) {
// See ion-java/issues/382 and ion-java/issues/383.
return;
}
File file = getTestdataFile("good/structOrdered.10n");
byte[] binary = _Private_Utils.loadFileBytes(file);
read(binary);
in.next();
Span pos = sr.currentSpan();
expectTopEof();
hoist(pos);
assertEquals(IonType.STRUCT, in.next());
expectTopEof();
}
use of com.amazon.ion.Span in project ion-java by amzn.
the class SeekableReaderTest method testHoistingLongValue.
@Test
public void testHoistingLongValue() {
if (getStreamingMode() == StreamingMode.NEW_STREAMING_INCREMENTAL) {
// See ion-java/issues/382 and ion-java/issues/383.
return;
}
// This value is "long" in that it has a length subfield in the prefix.
String text = " \"123456789012345\" ";
read(text);
in.next();
Span pos = sr.currentSpan();
expectTopEof();
hoist(pos);
assertEquals(IonType.STRING, in.next());
expectTopEof();
}
Aggregations