コード例 #1
0
  /**
   * Returns an XML <tt>String</tt> representation of this <tt>IQ</tt>.
   *
   * @return an XML <tt>String</tt> representation of this <tt>IQ</tt>
   */
  @Override
  public String getChildElementXML() {
    StringBuilder xml = new StringBuilder();

    xml.append('<').append(ELEMENT_NAME);
    xml.append(" xmlns='").append(NAMESPACE).append('\'');

    String id = getID();

    if (id != null) xml.append(' ').append(ID_ATTR_NAME).append("='").append(id).append('\'');

    List<Content> contents = getContents();

    if (contents.size() == 0) {
      xml.append(" />");
    } else {
      xml.append('>');
      for (Content content : contents) content.toXML(xml);
      xml.append("</").append(ELEMENT_NAME).append('>');
    }
    return xml.toString();
  }
コード例 #2
0
 /**
  * Returns a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
  * which has a specific name. If no such <tt>Content</tt> exists, returns <tt>null</tt>.
  *
  * @param contentName the name of the <tt>Content</tt> to be returned
  * @return a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
  *     which has the specified <tt>contentName</tt> if such a <tt>Content</tt> exists; otherwise,
  *     <tt>null</tt>
  */
 public Content getContent(String contentName) {
   for (Content content : getContents()) if (contentName.equals(content.getName())) return content;
   return null;
 }