/** * <p>Reads a Document from the given <code>File</code></p> * * @param file is the <code>File</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. * @throws java.net.MalformedURLException if a URL could not be made for the given File */ public Document read(File file) throws DocumentException, IOException, XmlPullParserException { String systemID = file.getAbsolutePath(); return read(new BufferedReader(new FileReader(file)), systemID); }
/** * <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 URL or filename.</p> * <p> * If the systemID contains a <code>':'</code> character then it is * assumed to be a URL otherwise its assumed to be a file name. * If you want finer grained control over this mechansim then please * explicitly pass in either a {@link URL} or a {@link File} instance * instead of a {@link String} to denote the source of the document. * </p> * * @param systemID is a URL for a document or a file name. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. * @throws java.net.MalformedURLException if a URL could not be made for the given File */ public Document read(String systemID) throws DocumentException, IOException, XmlPullParserException { if (systemID.indexOf(':') >= 0) { // lets assume its a URL return read(new URL(systemID)); } else { // lets assume that we are given a file name return read(new File(systemID)); } }
/** * <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); }
/** * <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)); }
protected HttpBindBody( String content ) throws DocumentException, XmlPullParserException, IOException { // Parse document from the content. document = getPacketReader().read( new StringReader( content ), "UTF-8" ); final Element node = document.getRootElement(); if ( node == null || !"body".equals( node.getName() ) ) { throw new IllegalArgumentException( "Root element 'body' is missing from parsed request data" ); } }
/** * <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); }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @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(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
Packet packet = null; Element element = localParser.get().read(new StringReader(packetXML)).getRootElement(); String tag = element.getName(); if ("message".equals(tag)) {
@OnWebSocketMessage public void onTextMethod(String stanza) { XMPPPacketReader reader = null; try { reader = readerPool.borrowObject(); Document doc = reader.read(new StringReader(stanza)); if (xmppSession == null) { initiateSession(doc.getRootElement()); } else { processStanza(doc.getRootElement()); } } catch (Exception ex) { Log.error("Failed to process XMPP stanza", ex); } finally { if (reader != null) { readerPool.returnObject(reader); } } }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { userJID = (JID) ExternalizableUtil.getInstance().readSerializable(in); name = ExternalizableUtil.getInstance().readSafeUTF(in); isDefault = ExternalizableUtil.getInstance().readBoolean(in); String xml = ExternalizableUtil.getInstance().readSafeUTF(in); try { Element element = localParser.get().read(new StringReader(xml)).getRootElement(); updateList(element, false); } catch (Exception e) { Log.error("Error while parsing Privacy Property", e); } } }
Element doc = reader.read(new StringReader(stanza)).getRootElement(); if (doc == null) {
/** * <p>Reads a Document from the given <code>File</code></p> * * @param file is the <code>File</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. * @throws java.net.MalformedURLException if a URL could not be made for the given File */ public Document read(File file) throws DocumentException, IOException, XmlPullParserException { String systemID = file.getAbsolutePath(); return read(new BufferedReader(new FileReader(file)), systemID); }
/** * <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 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); }
/** * <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); }
/** * <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)); }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @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(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
@OnWebSocketMessage public void onTextMethod(String stanza) { XMPPPacketReader reader = null; try { reader = readerPool.borrowObject(); Document doc = reader.read(new StringReader(stanza)); if (xmppSession == null) { initiateSession(doc.getRootElement()); } else { processStanza(doc.getRootElement()); } } catch (Exception ex) { Log.error("Failed to process XMPP stanza", ex); } finally { if (reader != null) { readerPool.returnObject(reader); } } }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { userJID = (JID) ExternalizableUtil.getInstance().readSerializable(in); name = ExternalizableUtil.getInstance().readSafeUTF(in); isDefault = ExternalizableUtil.getInstance().readBoolean(in); String xml = ExternalizableUtil.getInstance().readSafeUTF(in); try { Element element = localParser.get().read(new StringReader(xml)).getRootElement(); updateList(element, false); } catch (Exception e) { Log.error("Error while parsing Privacy Property", e); } } }