Search in sources :

Example 6 with AsyncByteArrayFeeder

use of com.fasterxml.aalto.AsyncByteArrayFeeder in project aalto-xml by FasterXML.

the class TestSurrogates method _testWithSurrogate.

private void _testWithSurrogate(final String spaces, final int chunkSize) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, spaces + DOC);
        _testWithSurrogate(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, spaces + DOC);
        _testWithSurrogate(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 7 with AsyncByteArrayFeeder

use of com.fasterxml.aalto.AsyncByteArrayFeeder in project aalto-xml by FasterXML.

the class AsyncReaderWrapperForByteArray method nextToken.

@Override
public int nextToken() throws XMLStreamException {
    int token;
    while ((token = _streamReader.next()) == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
        AsyncByteArrayFeeder feeder = _streamReader.getInputFeeder();
        if (!feeder.needMoreInput()) {
            AsyncTestBase.fail("Got EVENT_INCOMPLETE, could not feed more input");
        }
        if (_offset >= _xml.length) {
            // end-of-input?
            feeder.endOfInput();
        } else {
            int amount = Math.min(_bytesPerFeed, _xml.length - _offset);
            feeder.feedInput(_xml, _offset, amount);
            _offset += amount;
        }
    }
    return token;
}
Also used : AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder)

Example 8 with AsyncByteArrayFeeder

use of com.fasterxml.aalto.AsyncByteArrayFeeder in project aalto-xml by FasterXML.

the class TestCDataParsing method _testCData.

private void _testCData(final int chunkSize, final String SPC) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = f.createAsyncForByteArray();
    final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, SPC + XML);
    _testCData(sr_array, reader_array);
    sr_array.close();
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = f.createAsyncForByteBuffer();
    final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, SPC + XML);
    _testCData(sr_buffer, reader_buffer);
    sr_buffer.close();
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 9 with AsyncByteArrayFeeder

use of com.fasterxml.aalto.AsyncByteArrayFeeder in project aalto-xml by FasterXML.

the class TestCDataParsing method _testCDataSkip.

private void _testCDataSkip(final int chunkSize, final String SPC) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, SPC + XML);
        _testCDataSkip(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, SPC + XML);
        _testCDataSkip(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Example 10 with AsyncByteArrayFeeder

use of com.fasterxml.aalto.AsyncByteArrayFeeder in project aalto-xml by FasterXML.

the class TestCommentParsing method _testSkipComments.

private void _testSkipComments(final String spaces, final int chunkSize) throws Exception {
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, spaces + XML);
        _testSkipComments(sr_array, reader_array);
    } finally {
        if (sr_array != null) {
            sr_array.close();
        }
    }
    // test for byte buffer
    AsyncXMLStreamReader<AsyncByteBufferFeeder> sr_buffer = null;
    try {
        sr_buffer = f.createAsyncForByteBuffer();
        final AsyncReaderWrapperForByteBuffer reader_buffer = new AsyncReaderWrapperForByteBuffer(sr_buffer, chunkSize, spaces + XML);
        _testSkipComments(sr_buffer, reader_buffer);
    } finally {
        if (sr_buffer != null) {
            sr_buffer.close();
        }
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) AsyncByteArrayFeeder(com.fasterxml.aalto.AsyncByteArrayFeeder) InputFactoryImpl(com.fasterxml.aalto.stax.InputFactoryImpl) AsyncXMLInputFactory(com.fasterxml.aalto.AsyncXMLInputFactory)

Aggregations

AsyncByteArrayFeeder (com.fasterxml.aalto.AsyncByteArrayFeeder)25 AsyncXMLInputFactory (com.fasterxml.aalto.AsyncXMLInputFactory)24 InputFactoryImpl (com.fasterxml.aalto.stax.InputFactoryImpl)23 AsyncByteBufferFeeder (com.fasterxml.aalto.AsyncByteBufferFeeder)21 Result (io.georocket.input.Splitter.Result)1 XMLChunkMeta (io.georocket.storage.XMLChunkMeta)1 Window (io.georocket.util.Window)1 XMLStreamEvent (io.georocket.util.XMLStreamEvent)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1