Search in sources :

Example 6 with AsyncByteBufferFeeder

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

the class TestSurrogates method _testSkipWithSurrogate.

private void _testSkipWithSurrogate(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);
        _testSkipWithSurrogate(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);
        _testSkipWithSurrogate(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 AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder 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 8 with AsyncByteBufferFeeder

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

the class ManualIssue29Repro method run.

@Override
public void run() {
    try {
        ByteBuffer bb = StandardCharsets.UTF_8.encode(xml);
        AsyncXMLStreamReader<AsyncByteBufferFeeder> parser = inputFactory.createAsyncForByteBuffer();
        parser.getInputFeeder().feedInput(bb);
        while (parser.hasNext()) {
            int eventType = parser.next();
            if (eventType == AsyncXMLStreamReader.EVENT_INCOMPLETE) {
                break;
            }
            allocator.allocate(parser);
        }
    } catch (Exception e) {
        System.out.println("Error in " + count);
        e.printStackTrace();
    }
}
Also used : AsyncByteBufferFeeder(com.fasterxml.aalto.AsyncByteBufferFeeder) ByteBuffer(java.nio.ByteBuffer)

Example 9 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder 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 10 with AsyncByteBufferFeeder

use of com.fasterxml.aalto.AsyncByteBufferFeeder 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)

Aggregations

AsyncByteBufferFeeder (com.fasterxml.aalto.AsyncByteBufferFeeder)24 AsyncXMLInputFactory (com.fasterxml.aalto.AsyncXMLInputFactory)22 InputFactoryImpl (com.fasterxml.aalto.stax.InputFactoryImpl)22 AsyncByteArrayFeeder (com.fasterxml.aalto.AsyncByteArrayFeeder)21 ByteBuffer (java.nio.ByteBuffer)1