Search in sources :

Example 1 with Span

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);
}
Also used : OffsetSpan(com.amazon.ion.OffsetSpan) Span(com.amazon.ion.Span)

Example 2 with 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;
}
Also used : Span(com.amazon.ion.Span)

Example 3 with Span

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);
}
Also used : TextSpan(com.amazon.ion.TextSpan) TextSpan(com.amazon.ion.TextSpan) Spans.currentSpan(com.amazon.ion.util.Spans.currentSpan) Span(com.amazon.ion.Span)

Example 4 with Span

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();
}
Also used : File(java.io.File) Span(com.amazon.ion.Span) Test(org.junit.Test)

Example 5 with Span

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();
}
Also used : Span(com.amazon.ion.Span) Test(org.junit.Test)

Aggregations

Span (com.amazon.ion.Span)19 Test (org.junit.Test)14 TextSpan (com.amazon.ion.TextSpan)4 IonType (com.amazon.ion.IonType)3 OffsetSpan (com.amazon.ion.OffsetSpan)3 Spans.currentSpan (com.amazon.ion.util.Spans.currentSpan)3 IonDatagram (com.amazon.ion.IonDatagram)2 SpanProvider (com.amazon.ion.SpanProvider)1 File (java.io.File)1