public SAXReader createSAXReader(ErrorLogger errorLogger, EntityResolver entityResolver) { SAXReader saxReader = new SAXReader(); saxReader.setMergeAdjacentText( true ); saxReader.setValidation( true ); saxReader.setErrorHandler( errorLogger ); saxReader.setEntityResolver( entityResolver ); return saxReader; } }
/** * Adds the <code>ElementHandler</code> to be called when the * specified path is encounted. * * @param path is the path to be handled * @param handler is the <code>ElementHandler</code> to be called * by the event based processor. */ public void addHandler(String path, ElementHandler handler) { getDispatchHandler().addHandler(path, handler); }
/** * Removes the <code>ElementHandler</code> from the event based * processor, for the specified path. * * @param path is the path to remove the <code>ElementHandler</code> for. */ public void removeHandler(String path) { getDispatchHandler().removeHandler(path); }
public String toString(final Reflections reflections) { Document document = createDocument(reflections); try { StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint()); xmlWriter.write(document); xmlWriter.close(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(); } }
private void writeXML(Writer out, Project project) throws IOException { Document document = endDocument(project); XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint()); writer.write(document); }
protected XmlPartialSaver(ConfigElementImplementationRegistry registry, SystemEnvironment systemEnvironment) { this.registry = registry; this.systemEnvironment = systemEnvironment; reader = new SAXReader(); reader.setEntityResolver((publicId, systemId) -> new InputSource(new StringReader(""))); }
public SAXReader getSAXReader() { if ( reader == null ) { reader = new SAXReader(); reader.setMergeAdjacentText( true ); } return reader; }
/** * When multiple <code>ElementHandler</code> instances have been * registered, this will set a default <code>ElementHandler</code> * to be called for any path which does <b>NOT</b> have a handler * registered. * * @param handler is the <code>ElementHandler</code> to be called * by the event based processor. */ public void setDefaultHandler(ElementHandler handler) { getDispatchHandler().setDefaultHandler(handler); }
protected DispatchHandler getDispatchHandler() { if (dispatchHandler == null) { dispatchHandler = new DispatchHandler(); } return dispatchHandler; }
protected boolean isExpandEmptyElements() { return format.isExpandEmptyElements(); }
/** * <p>Reads a Document from the given stream</p> * * @param in <code>InputStream</code> to read from. * @param systemID is the URI for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(InputStream in, String systemID) throws DocumentException, IOException, XmlPullParserException { return read(createReader(in), systemID); }
@Override public XMPPPacketReader create() throws Exception { XMPPPacketReader parser = new XMPPPacketReader(); parser.setXPPFactory( xppFactory ); return parser; }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
/** * Returns the last time a full Document was read or a heartbeat was received. Hearbeats * are represented as whitespaces received while a Document is not being parsed. * * @return the time in milliseconds when the last document or heartbeat was received. */ long getLastActive() { return reader.getLastActive(); }
public MXParser getXPPParser() throws XmlPullParserException { if (xppParser == null) { xppParser = (MXParser) getXPPFactory().newPullParser(); } return xppParser; }
/** * <p>Reads a Document from the given stream</p> * * @param in <code>InputStream</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(InputStream in) throws DocumentException, IOException, XmlPullParserException { return read(createReader(in)); }
@Override protected XMPPPacketReader initialValue() { final XMPPPacketReader parser = new XMPPPacketReader(); parser.setXPPFactory( factory ); return parser; } };
/** * <p>Reads a Document from the given stream</p> * * @param charSet the charSet that the input is encoded in * @param in <code>InputStream</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(String charSet, InputStream in) throws DocumentException, IOException, XmlPullParserException { return read(createReader(in, charSet)); }
/** * <p>Reads a Document from the given <code>URL</code></p> * * @param url <code>URL</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(URL url) throws DocumentException, IOException, XmlPullParserException { String systemID = url.toExternalForm(); return read(createReader(url.openStream()), systemID); }