@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.halfOpenElement("title"); xml.attribute("type", "text"); xml.rightAngleBracket(); xml.escape(title); xml.closeElement("title"); String timeStamp = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(published); String idTag = "tag:" + XMPPSession.getInstance().getXMPPConnection().getUser().getDomain() + "," + timeStamp + ":posts-" + id; xml.element("id", idTag); xml.element("published", published); xml.element("updated", updated); xml.closeElement(this); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(ELEMENT); addCommonAttributes(buf); if (type != Type.available) { buf.attribute("type", type); } buf.rightAngleBracket(); buf.optElement("status", status); if (priority != Integer.MIN_VALUE) { buf.element("priority", Integer.toString(priority)); } if (mode != null && mode != Mode.available) { buf.element("show", mode); } buf.append(getExtensionsXML()); // Add the error sub-packet, if there is one. appendErrorIfExists(buf); buf.closeElement(ELEMENT); return buf; }
@Override public final XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(IQ_ELEMENT); addCommonAttributes(buf); if (type == null) { buf.attribute("type", "get"); } else { buf.attribute("type", type.toString()); } buf.rightAngleBracket(); buf.append(getChildElementXML()); buf.closeElement(IQ_ELEMENT); return buf; }
/** * Returns the error as XML. * * @return the error as XML. */ public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(ERROR); xml.attribute("type", type.toString()); xml.optAttribute("by", errorGenerator); xml.rightAngleBracket(); xml.halfOpenElement(condition.toString()); xml.xmlnsAttribute(NAMESPACE); if (conditionText != null) { xml.rightAngleBracket(); xml.escape(conditionText); xml.closeElement(condition.toString()); } else { xml.closeEmptyElement(); } addDescriptiveTextsAndExtensions(xml); xml.closeElement(ERROR); return xml; }
private boolean addEntryRaw (Item item) { XmlStringBuilder xml = new XmlStringBuilder(); xml.openElement("item"); xml.element("user", item.getUser()); xml.optElement("name", item.getName()); xml.optElement("type", item.getItemType()); xml.optElement("status", item.getItemStatus()); for (String groupName : item.getGroupNames()) { xml.openElement("group"); xml.element("groupName", groupName); xml.closeElement("group"); } xml.closeElement("item"); return FileUtils.writeFile(getBareJidFile(item.getUser()), xml.toString()); }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.optElement("after", after); xml.optElement("before", before); xml.optIntElement("count", count); if (firstString != null) { xml.halfOpenElement("first"); xml.optIntAttribute("index", firstIndex); xml.rightAngleBracket(); xml.append(firstString); xml.closeElement("first"); } xml.optIntElement("index", index); xml.optElement("last", last); xml.optIntElement("max", max); xml.closeElement(this); return xml; }
public XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(this); // Add attributes buf.optAttribute("label", getLabel()); buf.optAttribute("var", getVariable()); buf.optAttribute("type", getType()); buf.rightAngleBracket(); // Add elements buf.optElement("desc", getDescription()); buf.condEmptyElement(isRequired(), "required"); // Loop through all the values and append them to the string buffer for (String value : getValues()) { buf.element("value", value); } // Loop through all the values and append them to the string buffer for (Option option : getOptions()) { buf.append(option.toXML()); } buf.optElement(validateElement); buf.closeElement(this); return buf; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(this).attribute("type", type); buf.optAttribute("jid", jid); buf.optAttribute("node", node); buf.optAttribute("desc", description); if (description != null && description.trim().length() > 0) { buf.append(" desc=\""); buf.append(description).append("\""); } buf.optBooleanAttribute("delivered", delivered); buf.optAttribute("uri", uri); buf.closeEmptyElement(); return buf; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder builder = new XmlStringBuilder(this); builder.attribute("id", id); builder.closeEmptyElement(); return builder; }
@Override public CharSequence toXML() { XmlStringBuilder builder = new XmlStringBuilder(); builder.halfOpenElement("extraParams").xmlnsAttribute("jabber:client").rightAngleBracket(); Iterator<String> iterator = properties.keySet().iterator(); String key; while (iterator.hasNext()) { key = iterator.next(); builder.element(key, this.getProperty(key)); } builder.closeElement("extraParams"); return builder; }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("node", NODE + "/" + blogPostId); xml.rightAngleBracket(); xml.halfOpenElement("item"); xml.attribute("id", id); xml.rightAngleBracket(); xml.halfOpenElement("entry"); xml.xmlnsAttribute("http://www.w3.org/2005/Atom"); xml.rightAngleBracket(); xml.openElement("author"); xml.element("name", authorName); xml.element("uri", "xmpp:" + authorJid); xml.closeElement("author"); xml.halfOpenElement("title"); xml.attribute("type", "text"); xml.rightAngleBracket(); xml.escape(content); xml.closeElement("title"); xml.element("published", published); xml.closeElement("entry"); xml.closeElement("item"); xml.closeElement(this); return xml; }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("node", NODE); xml.rightAngleBracket(); xml.halfOpenElement("item"); xml.attribute("id", id); xml.rightAngleBracket(); xml.halfOpenElement("entry"); xml.xmlnsAttribute("http://www.w3.org/2005/Atom"); xml.rightAngleBracket(); xml.halfOpenElement("title"); xml.attribute("type", "text"); xml.rightAngleBracket(); xml.escape(title); xml.closeElement("title"); Date today = Calendar.getInstance().getTime(); String timeStamp = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(today); String idTag = "tag:" + jid.getDomain() + "," + timeStamp + ":posts-" + id; xml.element("id", idTag); xml.element("published", today); xml.element("updated", today); xml.closeElement("entry"); xml.closeElement("item"); xml.closeElement(this); return xml; }
protected void maybeAddResumeAttributeTo(XmlStringBuilder xml) { if (resume) { // XEP 198 never mentions the case where resume='false', it's either set to true or // not set at all. We reflect this in this code part xml.attribute("resume", "true"); } }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); maybeAddResumeAttributeTo(xml); maybeAddMaxAttributeTo(xml); xml.closeEmptyElement(); return xml; }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.optAttribute("id", id); maybeAddResumeAttributeTo(xml); xml.optAttribute("location", location); maybeAddMaxAttributeTo(xml); xml.closeEmptyElement(); return xml; }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); if (condition != null) { xml.rightAngleBracket(); xml.append(condition.toString()); xml.xmlnsAttribute(XMPPError.NAMESPACE); xml.closeElement(ELEMENT); } else { xml.closeEmptyElement(); } return xml; }
@Override public final XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("h", Long.toString(handledCount)); xml.attribute("previd", previd); xml.closeEmptyElement(); return xml; }
@Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("h", Long.toString(handledCount)); xml.closeEmptyElement(); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.append(fwd.toXML()); xml.closeElement(this); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.optAppend(text); xml.closeElement(this); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("streamId", streamId); xml.closeEmptyElement(); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("sid", sid); xml.closeEmptyElement(); return xml; }
@Override public final XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.append(json); xml.closeElement(this); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).attribute("mechanism", mechanism).rightAngleBracket(); xml.optAppend(authenticationText); xml.closeElement(ELEMENT); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder().halfOpenElement(ELEMENT).xmlnsAttribute( NAMESPACE).rightAngleBracket(); xml.optAppend(data); xml.closeElement(ELEMENT); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket(); xml.optAppend(authenticationText); xml.closeElement(ELEMENT); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket(); xml.optAppend(data); xml.closeElement(ELEMENT); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket(); xml.emptyElement(saslErrorString); addDescriptiveTextsAndExtensions(xml); xml.closeElement(ELEMENT); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); xml.element("method", method); xml.closeElement(this); return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.rightAngleBracket(); for (String method : methods) { xml.element("method", method); } xml.closeElement(this); return xml; }
@Override public CharSequence toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(elementName).xmlnsAttribute(namespace).rightAngleBracket(); for (String name : getNames()) { String value = getValue(name); buf.element(name, value); } buf.closeElement(elementName); return buf; }
protected void addDescriptiveTextsAndExtensions(XmlStringBuilder xml) { for (Map.Entry<String, String> entry : descriptiveTexts.entrySet()) { String xmllang = entry.getKey(); String text = entry.getValue(); xml.halfOpenElement("text").xmlnsAttribute(textNamespace) .xmllangAttribute(xmllang).rightAngleBracket(); xml.escape(text); xml.closeElement("text"); } for (ExtensionElement packetExtension : extensions) { xml.append(packetExtension.toXML()); } }
/** * Returns the sub-element XML section of the IQ packet, or the empty String if there * isn't one. * * @return the child element section of the IQ XML. */ public final XmlStringBuilder getChildElementXML() { XmlStringBuilder xml = new XmlStringBuilder(); if (type == Type.error) { // Add the error sub-packet, if there is one. appendErrorIfExists(xml); } else if (childElementName != null) { // Add the query section if there is one. IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this)); if (iqChildElement != null) { xml.append(iqChildElement); XmlStringBuilder extensionsXml = getExtensionsXML(); if (iqChildElement.isEmptyElement) { if (extensionsXml.length() == 0) { xml.closeEmptyElement(); return xml; } else { xml.rightAngleBracket(); } } xml.append(extensionsXml); xml.closeElement(iqChildElement.element); } } return xml; }
@Override public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); if (optional) { xml.rightAngleBracket(); xml.emptyElement(OPTIONAL_ELEMENT); xml.closeElement(this); } else { xml.closeEmptyElement(); } return xml; }
/** * Returns the extension sub-packets (including properties data) as an XML * String, or the Empty String if there are no stanza(/packet) extensions. * * @return the extension sub-packets as XML or the Empty String if there * are no stanza(/packet) extensions. */ protected final XmlStringBuilder getExtensionsXML() { XmlStringBuilder xml = new XmlStringBuilder(); // Add in all standard extension sub-packets. for (ExtensionElement extension : getExtensions()) { xml.append(extension.toXML()); } return xml; }