com.fasterxml.aalto.AsyncXMLStreamReader Java Examples
The following examples show how to use
com.fasterxml.aalto.AsyncXMLStreamReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlStreamDecoder.java From onos with Apache License 2.0 | 6 votes |
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { AsyncByteArrayFeeder streamFeeder = streamReader.getInputFeeder(); logger.info("Decoding XMPP data.. "); byte[] buffer = new byte[in.readableBytes()]; in.readBytes(buffer); logger.debug("Buffer length: " + buffer.length); try { streamFeeder.feedInput(buffer, 0, buffer.length); } catch (XMLStreamException exception) { logger.info(exception.getMessage()); in.skipBytes(in.readableBytes()); logger.info("Bytes skipped"); throw exception; } while (streamReader.hasNext() && streamReader.next() != AsyncXMLStreamReader.EVENT_INCOMPLETE) { out.add(allocator.allocate(streamReader)); } }
Example #2
Source File: XmlEventDecoder.java From spring-analysis-note with MIT License | 5 votes |
@Override public List<? extends XMLEvent> apply(DataBuffer dataBuffer) { try { this.streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer()); List<XMLEvent> events = new ArrayList<>(); while (true) { if (this.streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) { // no more events with what currently has been fed to the reader break; } else { XMLEvent event = this.eventAllocator.allocate(this.streamReader); events.add(event); if (event.isEndDocument()) { break; } } } return events; } catch (XMLStreamException ex) { throw Exceptions.propagate(ex); } finally { DataBufferUtils.release(dataBuffer); } }
Example #3
Source File: XmlEventDecoder.java From java-technology-stack with MIT License | 5 votes |
@Override public Publisher<? extends XMLEvent> apply(DataBuffer dataBuffer) { try { this.streamReader.getInputFeeder().feedInput(dataBuffer.asByteBuffer()); List<XMLEvent> events = new ArrayList<>(); while (true) { if (this.streamReader.next() == AsyncXMLStreamReader.EVENT_INCOMPLETE) { // no more events with what currently has been fed to the reader break; } else { XMLEvent event = this.eventAllocator.allocate(this.streamReader); events.add(event); if (event.isEndDocument()) { break; } } } return Flux.fromIterable(events); } catch (XMLStreamException ex) { return Mono.error(ex); } finally { DataBufferUtils.release(dataBuffer); } }
Example #4
Source File: XmlMergerTest.java From onos with Apache License 2.0 | 5 votes |
private void initXmlEventList(List<Object> xmlEventList, String xmlMessage) throws XMLStreamException, UnsupportedEncodingException { AsyncByteArrayFeeder streamFeeder = streamReader.getInputFeeder(); byte[] buffer = xmlMessage.getBytes("UTF-8"); streamFeeder.feedInput(buffer, 0, buffer.length); while (streamReader.hasNext() && streamReader.next() != AsyncXMLStreamReader.EVENT_INCOMPLETE) { xmlEventList.add(allocator.allocate(streamReader)); } }