/** * Sets the error condition. * * @param condition the error condition. * @see Condition */ public void setCondition(Condition condition) { if (condition == null) { throw new ArgumentException("Condition cannot be null"); } XElement conditionElement = null; for (Iterator<Element> i=element.elementIterator(); i.hasNext(); ) { XElement el = i.next(); if (el.getNamespaceURI().equals(ERROR_NAMESPACE) && !el.getName().equals("text")) { conditionElement = el; } } if (conditionElement != null) { conditionElement.Remove(); } conditionElement = docFactory.createElement(condition.toXMPP(), ERROR_NAMESPACE); element.Add(conditionElement); }
/** * Sets the error condition. * * @param condition the error condition. * @see Condition */ public void setCondition(Condition condition) { if (condition == null) { throw new NullPointerException("Condition cannot be null"); } // Set the error code for legacy support. element.addAttribute("code", Integer.toString(condition.getLegacyCode())); Element conditionElement = null; for (Iterator<Element> i=element.elementIterator(); i.hasNext(); ) { Element el = i.next(); if (el.getNamespaceURI().equals(ERROR_NAMESPACE) && !el.getName().equals("text")) { conditionElement = el; } } if (conditionElement != null) { element.remove(conditionElement); } conditionElement = docFactory.createElement(condition.toXMPP(), ERROR_NAMESPACE); element.add(conditionElement); }