private AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException { NamedElement child = null; boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals(ELEMENT_TEXT)) { child = parseText(parser); } else if (parser.getName().equals(ELEMENT_BASE_64)) { child = parseBase64(parser); } else if (parser.getName().equals(ELEMENT_CHUNKED_BASE_64)) { child = parseChunkedBase64(parser); } else if (parser.getName().equals(ELEMENT_XML)) { child = parseXml(parser); } else if (parser.getName().equals(ELEMENT_IBB)) { child = parseIbb(parser); } else if (parser.getName().equals(ELEMENT_SIPUB)) { // TODO: sipub is allowed by xep-0332, but is not implemented yet throw new UnsupportedOperationException("sipub is not supported yet"); } else if (parser.getName().equals(ELEMENT_JINGLE)) { // TODO: jingle is allowed by xep-0332, but is not implemented yet throw new UnsupportedOperationException("jingle is not supported yet"); } else { // other elements are not allowed throw new IllegalArgumentException("unsupported child tag: " + parser.getName()); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(ELEMENT_DATA)) { done = true; } } } AbstractHttpOverXmpp.Data data = new AbstractHttpOverXmpp.Data(child); return data; }
@Override public XmlStringBuilder toXML() { // Upcast to NamedElement since we don't want a xmlns attribute XmlStringBuilder xml = new XmlStringBuilder((NamedElement) this); xml.attribute("name", name); xml.rightAngleBracket(); xml.escape(value); xml.closeElement(this); return xml; }
public XmlStringBuilder(NamedElement e) { this(); halfOpenElement(e.getElementName()); }
public XmlStringBuilder halfOpenElement(NamedElement namedElement) { return halfOpenElement(namedElement.getElementName()); }
public XmlStringBuilder closeElement(NamedElement e) { closeElement(e.getElementName()); return this; }
/** * Creates Data element. * * @param child element nested by Data */ public Data(NamedElement child) { this.child = child; }
/** * Returns element nested by Data. * * @return element nested by Data */ public NamedElement getChild() { return child; }