package org.jivesoftware.smack.compress.packet;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.FullStreamElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.util.XmlStringBuilder;

public class Compress extends FullStreamElement {
   public static final String ELEMENT = "compress";
   public static final String NAMESPACE = "http://jabber.org/protocol/compress";
   public final String method;

   public Compress(String method) {
      this.method = method;
   }

   public String getElementName() {
      return "compress";
   }

   public String getNamespace() {
      return "http://jabber.org/protocol/compress";
   }

   public XmlStringBuilder toXML() {
      XmlStringBuilder xml = new XmlStringBuilder(this);
      xml.rightAngleBracket();
      xml.element("method", this.method);
      xml.closeElement((NamedElement)this);
      return xml;
   }

   public static class Feature implements ExtensionElement {
      public static final String ELEMENT = "compression";
      public final List<String> methods;

      public Feature(List<String> methods) {
         this.methods = methods;
      }

      public List<String> getMethods() {
         return Collections.unmodifiableList(this.methods);
      }

      public String getNamespace() {
         return "http://jabber.org/protocol/compress";
      }

      public String getElementName() {
         return "compression";
      }

      public XmlStringBuilder toXML() {
         XmlStringBuilder xml = new XmlStringBuilder(this);
         xml.rightAngleBracket();
         Iterator i$ = this.methods.iterator();

         while(i$.hasNext()) {
            String method = (String)i$.next();
            xml.element("method", method);
         }

         xml.closeElement((NamedElement)this);
         return xml;
      }
   }
}
