Search in sources :

Example 21 with AsyncByteBufferFeeder

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

the class TestCharactersParsing method _testTextWithNumericEntities.

private void _testTextWithNumericEntities(final int chunkSize, final boolean checkValues, final String SPC) throws Exception {
    final String XML = SPC + "<root>&#60;tag&#x3e;!</root>";
    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, XML);
        _testTextWithNumericEntities(sr_array, reader_array, checkValues);
    } 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, XML);
        _testTextWithNumericEntities(sr_buffer, reader_buffer, checkValues);
    } 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 22 with AsyncByteBufferFeeder

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

the class TestDoctypeParsing method _testFull.

private void _testFull(final String spaces, final boolean checkValue, final int chunkSize) throws Exception {
    final String SYSTEM_ID = "file:/something";
    final String INTERNAL_SUBSET = "<!--My dtd-->\n" + "<!ELEMENT html (head, body)>" + "<!ATTLIST head title CDATA #IMPLIED>";
    String XML = spaces + "<!DOCTYPE root SYSTEM '" + SYSTEM_ID + "' [" + INTERNAL_SUBSET + "]>\n<root/>";
    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, XML);
        _testFull(sr_array, reader_array, checkValue, SYSTEM_ID, INTERNAL_SUBSET);
    } 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, XML);
        _testFull(sr_buffer, reader_buffer, checkValue, SYSTEM_ID, INTERNAL_SUBSET);
    } 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 23 with AsyncByteBufferFeeder

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

the class TestDoctypeParsing method _testWithIds.

private void _testWithIds(String spaces, int chunkSize, String PUBLIC_ID, String SYSTEM_ID) throws Exception {
    final String XML = spaces + "<!DOCTYPE root PUBLIC '" + PUBLIC_ID + "' \"" + SYSTEM_ID + "\"><root/>";
    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, XML);
        _testWithIds(sr_array, reader_array, PUBLIC_ID, SYSTEM_ID);
    } 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, XML);
        _testWithIds(sr_buffer, reader_buffer, PUBLIC_ID, SYSTEM_ID);
    } 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 24 with AsyncByteBufferFeeder

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

the class TestEntityParsing method _testEntity.

/*
    /**********************************************************************
    /* Secondary test methods
    /**********************************************************************
     */
private void _testEntity(final int chunkSize, final boolean checkValues, final String spaces) throws Exception {
    final String XML = spaces + "<root>&entity1;Some text&entity2;!<leaf>...&leafEntity;</leaf>&last;</root>";
    final AsyncXMLInputFactory f = new InputFactoryImpl();
    // important must not require expansion of general entities
    f.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
    // test for byte array
    AsyncXMLStreamReader<AsyncByteArrayFeeder> sr_array = null;
    try {
        sr_array = f.createAsyncForByteArray();
        final AsyncReaderWrapperForByteArray reader_array = new AsyncReaderWrapperForByteArray(sr_array, chunkSize, XML);
        _testEntity(sr_array, reader_array, checkValues);
    } 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, XML);
        _testEntity(sr_buffer, reader_buffer, checkValues);
    } 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