/** * Parses content from given reader input stream. */ public void parseXml(Reader reader) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, this.defaultNamespaceDictionary, null); }
/** * Parses content from given reader input stream. */ public void parseXml(Reader reader) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, this.defaultNamespaceDictionary, null); }
/** * Parses content from given reader input stream and namespace dictionary. */ protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null); } }
/** * Parses content from given reader input stream and namespace dictionary. */ protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null); } }
@Override protected Object parseEntryInternal() throws IOException, XmlPullParserException { XmlPullParser parser = this.parser; String kind = parser.getAttributeValue(GoogleAtom.GD_NAMESPACE, "kind"); Class<?> entryClass = this.kindToEntryClassMap.get(kind); if (entryClass == null) { throw new IllegalArgumentException("unrecognized kind: " + kind); } Object result = Types.newInstance(entryClass); Xml.parseElement(parser, result, namespaceDictionary, null); return result; }
private Object readObject(XmlPullParser parser, Type dataType) throws XmlPullParserException, IOException { Preconditions.checkArgument(dataType instanceof Class<?>, "dataType has to be of Class<?>"); Object result = Types.newInstance((Class<?>) dataType); Xml.parseElement(parser, result, namespaceDictionary, null); return result; }
/** * Parse the next item in the feed and return a new parsed instance of the item type. If there is * no item to parse, it will return {@code null} and automatically close the parser (in which case * there is no need to call {@link #close()}. * * @throws IOException I/O exception * @throws XmlPullParserException XML pull parser exception */ public Object parseNextEntry() throws IOException, XmlPullParserException { if (!feedParsed) { feedParsed = true; Xml.parseElement(parser, null, namespaceDictionary, Atom.StopAtAtomEntry.INSTANCE); } boolean close = true; try { if (parser.getEventType() == XmlPullParser.START_TAG) { Object result = parseEntryInternal(); parser.next(); close = false; return result; } } finally { if (close) { close(); } } return null; }
@Override protected Object parseEntryInternal() throws IOException, XmlPullParserException { E result = Types.newInstance(entryClass); Xml.parseElement(getParser(), result, getNamespaceDictionary(), null); return result; }
/** * Parse the feed and return a new parsed instance of the feed type. This method can be skipped if * all you want are the items. * * @throws IOException I/O exception * @throws XmlPullParserException XML pull parser exception */ public T parseFeed() throws IOException, XmlPullParserException { boolean close = true; try { this.feedParsed = true; T result = Types.newInstance(feedClass); Xml.parseElement(parser, result, namespaceDictionary, Atom.StopAtAtomEntry.INSTANCE); close = false; return result; } finally { if (close) { close(); } } }