MamFinIQ.java

  1. /**
  2.  *
  3.  * Copyright © 2016 Fernando Ramirez
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.mam.element;

  18. import org.jivesoftware.smack.packet.IQ;

  19. import org.jivesoftware.smackx.rsm.packet.RSMSet;

  20. /**
  21.  * MAM fin IQ class.
  22.  *
  23.  * @see <a href="http://xmpp.org/extensions/xep-0313.html">XEP-0313: Message
  24.  *      Archive Management</a>
  25.  * @author Fernando Ramirez
  26.  *
  27.  */
  28. public class MamFinIQ extends IQ {

  29.     /**
  30.      * fin element.
  31.      */
  32.     public static final String ELEMENT = "fin";

  33.     /**
  34.      * RSM set.
  35.      */
  36.     private final RSMSet rsmSet;

  37.     /**
  38.      * if is complete.
  39.      */
  40.     private final boolean complete;

  41.     /**
  42.      * if is stable.
  43.      */
  44.     private final boolean stable;

  45.     /**
  46.      * the query id.
  47.      */
  48.     private final String queryId;

  49.     /**
  50.      * MamFinIQ constructor.
  51.      *
  52.      * @param version TODO javadoc me please
  53.      * @param queryId TODO javadoc me please
  54.      * @param rsmSet TODO javadoc me please
  55.      * @param complete TODO javadoc me please
  56.      * @param stable TODO javadoc me please
  57.      */
  58.     public MamFinIQ(MamVersion version, String queryId, RSMSet rsmSet, boolean complete, boolean stable) {
  59.         super(ELEMENT, version.getNamespace());
  60.         if (rsmSet == null) {
  61.             throw new IllegalArgumentException("rsmSet must not be null");
  62.         }
  63.         this.rsmSet = rsmSet;
  64.         this.complete = complete;
  65.         this.stable = stable;
  66.         this.queryId = queryId;
  67.     }

  68.     /**
  69.      * Get RSM set.
  70.      *
  71.      * @return the RSM set
  72.      */
  73.     public RSMSet getRSMSet() {
  74.         return rsmSet;
  75.     }

  76.     /**
  77.      * Return if it is complete.
  78.      *
  79.      * @return true if it is complete
  80.      */
  81.     public boolean isComplete() {
  82.         return complete;
  83.     }

  84.     /**
  85.      * Return if it is stable.
  86.      *
  87.      * @return true if it is stable
  88.      */
  89.     public boolean isStable() {
  90.         return stable;
  91.     }

  92.     /**
  93.      * Get query id.
  94.      *
  95.      * @return the query id
  96.      */
  97.     public final String getQueryId() {
  98.         return queryId;
  99.     }

  100.     @Override
  101.     protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
  102.         xml.optAttribute("queryid", queryId);
  103.         xml.optBooleanAttribute("complete", complete);
  104.         xml.optBooleanAttribute("stable", stable);
  105.         if (rsmSet == null) {
  106.             xml.setEmptyElement();
  107.         } else {
  108.             xml.rightAngleBracket();
  109.             xml.append(rsmSet);
  110.         }
  111.         return xml;
  112.     }

  113. }