DisablePushNotificationsIQ.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.push_notifications.element;

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

  19. import org.jxmpp.jid.Jid;

  20. /**
  21.  * Disable Push Notifications IQ.
  22.  *
  23.  * @see <a href="http://xmpp.org/extensions/xep-0357.html">XEP-0357: Push
  24.  *      Notifications</a>
  25.  * @author Fernando Ramirez
  26.  *
  27.  */
  28. public class DisablePushNotificationsIQ extends IQ {

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

  33.     /**
  34.      * the IQ NAMESPACE.
  35.      */
  36.     public static final String NAMESPACE = PushNotificationsElements.NAMESPACE;

  37.     private final Jid jid;
  38.     private final String node;

  39.     public DisablePushNotificationsIQ(Jid jid, String node) {
  40.         super(ELEMENT, NAMESPACE);
  41.         this.jid = jid;
  42.         this.node = node;
  43.         this.setType(Type.set);
  44.     }

  45.     public DisablePushNotificationsIQ(Jid jid) {
  46.         this(jid, null);
  47.     }

  48.     /**
  49.      * Get the JID.
  50.      *
  51.      * @return the JID
  52.      */
  53.     public Jid getJid() {
  54.         return jid;
  55.     }

  56.     /**
  57.      * Get the node.
  58.      *
  59.      * @return the node
  60.      */
  61.     public String getNode() {
  62.         return node;
  63.     }

  64.     @Override
  65.     protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
  66.         xml.attribute("jid", jid);
  67.         xml.optAttribute("node", node);
  68.         xml.rightAngleBracket();
  69.         return xml;
  70.     }

  71. }