static public XMLStreamReaderHandle XMLStreamReaderToHandle(XMLStreamReader value) { return (value == null) ? null : new XMLStreamReaderHandle(value); } static public Stream<XMLStreamReaderHandle> XMLStreamReaderToHandle(Stream<? extends XMLStreamReader> values) {
@Override public byte[] toBuffer() { try { if (content == null) return null; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); write(buffer); byte[] b = buffer.toByteArray(); fromBuffer(b); return b; } catch (IOException e) { throw new MarkLogicIOException(e); } } /**
/** * Assigns an stream reader for the content and returns the handle * as a fluent convenience. * @param content a StAX stream reader * @return this handle */ public XMLStreamReaderHandle with(XMLStreamReader content) { set(content); return this; }
XMLStreamReaderHandle streamHandle = new XMLStreamReaderHandle(); streamHandle.set( streamHandle.getFactory().createXMLStreamReader( new StringReader(docIn)
assertXMLEqual("EventReader buffering",beforeStr,new String(after)); XMLStreamReaderHandle streamReaderH = new XMLStreamReaderHandle(); streamReaderH.fromBuffer(before); after = streamReaderH.toBuffer(); assertNotNull("StreamReader after",after); assertXMLEqual("StreamReader buffering",beforeStr,new String(after));
System.out.println(result.getUri() + ": Uri"); XMLStreamReaderHandle shandle = queryMgr.search(querydef, new XMLStreamReaderHandle()); String resultDoc2 = shandle.toString(); System.out.println("Statics : \n" + resultDoc2);
new ArrayList<>() : null; XMLStreamReader headerReader = headerRow.getContent(new XMLStreamReaderHandle()).get(); while (headerReader.hasNext()) { switch(headerReader.next()) {
counter.get("elementCount") == 2 && counter.get("attributeCount") == 2); XMLStreamReaderHandle streamReaderHandle = docMgr.read(docId, new XMLStreamReaderHandle()); XMLStreamReader streamReader = streamReaderHandle.get(); int elementCount = 0; int attributeCount = 0; attributeCount += elementAttributeCount; streamReaderHandle.close(); assertTrue("Failed to process XML document with StAX stream reader", elementCount == 2 && attributeCount == 2);
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
XMLStreamReader fileRead = readHandle.get(); String readContent = convertXMLStreamReaderToString(fileRead);
/** * Buffers the StAX stream and returns the buffer as an XML string. */ @Override public String toString() { try { return new String(toBuffer(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new MarkLogicIOException(e); } }
/** * Returns the factory for parsing StAX streams. * @return the StAX factory */ public XMLInputFactory getFactory() { if (factory == null) factory = makeXMLInputFactory(); return factory; } /**
@Override public void fromBuffer(byte[] buffer) { if (buffer == null || buffer.length == 0) content = null; else receiveContent(new ByteArrayInputStream(buffer)); } @Override
/** * Specifies the mime type of the content and returns the handle * as a fluent convenience. * @param mimetype the mime type of the content * @return this handle */ public XMLStreamReaderHandle withMimetype(String mimetype) { setMimetype(mimetype); return this; }
public static HandleFactoryRegistry registerDefaults(HandleFactoryRegistry registry) { registry.register(BytesHandle.newFactory()); registry.register(DOMHandle.newFactory()); registry.register(FileHandle.newFactory()); registry.register(InputSourceHandle.newFactory()); registry.register(InputStreamHandle.newFactory()); registry.register(ReaderHandle.newFactory()); registry.register(SourceHandle.newFactory()); registry.register(StringHandle.newFactory()); registry.register(XMLEventReaderHandle.newFactory()); registry.register(XMLStreamReaderHandle.newFactory()); return registry; }
System.out.println(result.getUri() + ": Uri"); XMLStreamReaderHandle shandle = queryMgr.search(querydef, new XMLStreamReaderHandle()); String resultDoc2 = shandle.toString(); System.out.println("Statics : \n" + resultDoc2);
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); this.contentSource = content; } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
XMLStreamReader fileRead = readHandle.get(); String readContent = convertXMLStreamReaderToString(fileRead);
/** * Buffers the StAX stream and returns the buffer as an XML string. */ @Override public String toString() { try { return new String(toBuffer(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new MarkLogicIOException(e); } }
/** * Returns the factory for parsing StAX streams. * @return the StAX factory */ public XMLInputFactory getFactory() { if (factory == null) factory = makeXMLInputFactory(); return factory; } /**