@Override public String toString() { StringBuilder sb = new StringBuilder("XMPPError: "); sb.append(condition.toString()).append(" - ").append(type.toString()); if (errorGenerator != null) { sb.append(". Generated by ").append(errorGenerator); } return sb.toString(); }
@Override public CharSequence toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); if (condition == null && textElements.isEmpty()) { xml.closeEmptyElement(); } else { if (condition != null) { xml.rightAngleBracket(); xml.append(condition.toString()); xml.xmlnsAttribute(StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE); xml.closeEmptyElement(); } xml.append(textElements); xml.closeElement(ELEMENT); } return xml; }
@Test public void testParseFailedError() throws Exception { StanzaError.Condition errorCondition = StanzaError.Condition.unexpected_request; String failedStanza = XMLBuilder.create("failed") .a("xmlns", "urn:xmpp:sm:3") .element(errorCondition.toString(), StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE) .asString(outputProperties); StreamManagement.Failed failedPacket = ParseStreamManagement.failed( PacketParserUtils.getParserFor(failedStanza)); assertThat(failedPacket, is(notNullValue())); assertTrue(failedPacket.getStanzaErrorCondition() == errorCondition); }
.getCondition() .equals(StanzaError.Condition.conflict .toString())) { return;
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); xml.attribute("type", type.toString()); xml.optAttribute("by", errorGenerator); xml.rightAngleBracket(); xml.halfOpenElement(condition.toString()); xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE); if (conditionText != null) { xml.rightAngleBracket(); xml.escape(conditionText); xml.closeElement(condition.toString()); } else { xml.closeEmptyElement(); } addDescriptiveTextsAndExtensions(xml); xml.closeElement(this); return xml; }
@Override public String toString() { StringBuilder sb = new StringBuilder("XMPPError: "); sb.append(condition.toString()).append(" - ").append(type.toString()); if (errorGenerator != null) { sb.append(". Generated by ").append(errorGenerator); } return sb.toString(); }
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace); xml.attribute("type", type.toString()); xml.optAttribute("by", errorGenerator); xml.rightAngleBracket(); xml.halfOpenElement(condition.toString()); xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE); if (conditionText != null) { xml.rightAngleBracket(); xml.escape(conditionText); xml.closeElement(condition.toString()); } else { xml.closeEmptyElement(); } addDescriptiveTextsAndExtensions(xml); xml.closeElement(this); return xml; }