static public InputSourceHandle InputSourceToHandle(InputSource value) { return (value == null) ? null : new InputSourceHandle(value); } static public Stream<InputSourceHandle> InputSourceToHandle(Stream<? extends InputSource> values) {
/** * Creates a factory to create a InputSourceHandle instance for a SAX InputSource. * @return the factory */ static public ContentHandleFactory newFactory() { return new ContentHandleFactory() { @Override public Class<?>[] getHandledClasses() { return new Class<?>[]{ InputSource.class }; } @Override public boolean isHandled(Class<?> type) { return InputSource.class.isAssignableFrom(type); } @Override public <C> ContentHandle<C> newHandle(Class<C> type) { @SuppressWarnings("unchecked") ContentHandle<C> handle = isHandled(type) ? (ContentHandle<C>) new InputSourceHandle() : null; return handle; } }; }
/** * Creates a factory to create a InputSourceHandle instance for a SAX InputSource. * @return the factory */ static public ContentHandleFactory newFactory() { return new ContentHandleFactory() { @Override public Class<?>[] getHandledClasses() { return new Class<?>[]{ InputSource.class }; } @Override public boolean isHandled(Class<?> type) { return InputSource.class.isAssignableFrom(type); } @Override public <C> ContentHandle<C> newHandle(Class<C> type) { @SuppressWarnings("unchecked") ContentHandle<C> handle = isHandled(type) ? (ContentHandle<C>) new InputSourceHandle() : null; return handle; } }; }
@Override public <C> ContentHandle<C> newHandle(Class<C> type) { @SuppressWarnings("unchecked") ContentHandle<C> handle = isHandled(type) ? (ContentHandle<C>) new InputSourceHandle() : null; return handle; } };
@Override public <C> ContentHandle<C> newHandle(Class<C> type) { @SuppressWarnings("unchecked") ContentHandle<C> handle = isHandled(type) ? (ContentHandle<C>) new InputSourceHandle() : null; return handle; } };
/** * Reading document using InputSourceHandle * * @param client * @param uri * @param type * @return */ public InputSourceHandle readDocumentUsingInputSourceHandle(DatabaseClient client, String uri, String type) { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // create handle InputSourceHandle contentHandle = new InputSourceHandle(); // create doc id String readDocId = uri; System.out.println("Read " + readDocId + " from database"); docMgr.read(readDocId, contentHandle); return contentHandle; }
"<root foo='bar'><child/>mixed</root>"; InputSourceHandle saxHandle = new InputSourceHandle();
assertXMLEqual("Transform result not equivalent to source",domString,docText); InputSourceHandle saxHandle = new InputSourceHandle(); saxHandle.set(new InputSource(new StringReader(domString))); docMgr.write(docId, saxHandle);
assertXMLEqual("DOM buffering",beforeStr,new String(after)); InputSourceHandle inputSourceH = new InputSourceHandle(); inputSourceH.fromBuffer(before); after = inputSourceH.toBuffer();
validateClosingHandleClosesUnderlyingStream(new DOM4JHandle(), "<xml/>"); validateClosingHandleClosesUnderlyingStream(new GSONHandle(), "null"); validateClosingHandleClosesUnderlyingStream(new InputSourceHandle(), "testing"); validateClosingHandleClosesUnderlyingStream(new InputStreamHandle(), "testing"); validateClosingHandleClosesUnderlyingStream(new JacksonHandle(), "null");