OfflineMessageHeader.java

  1. /**
  2.  *
  3.  * Copyright 2003-2007 Jive Software.
  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.offline;

  18. import org.jivesoftware.smackx.disco.packet.DiscoverItems;

  19. import org.jxmpp.jid.Jid;

  20. /**
  21.  * The OfflineMessageHeader holds header information of an offline message. The header
  22.  * information was retrieved using the {@link OfflineMessageManager} class.<p>
  23.  *
  24.  * Each offline message is identified by the target user of the offline message and a unique stamp.
  25.  * Use {@link OfflineMessageManager#getMessages(java.util.List)} to retrieve the whole message.
  26.  *
  27.  * @author Gaston Dombiak
  28.  */
  29. public class OfflineMessageHeader {
  30.     /**
  31.      * Bare JID of the user that was offline when the message was sent.
  32.      */
  33.     private Jid user;
  34.     /**
  35.      * Full JID of the user that sent the message.
  36.      */
  37.     private String jid;
  38.     /**
  39.      * Stamp that uniquely identifies the offline message. This stamp will be used for
  40.      * getting the specific message or delete it. The stamp may be of the form UTC timestamps
  41.      * but it is not required to have that format.
  42.      */
  43.     private String stamp;

  44.     public OfflineMessageHeader(DiscoverItems.Item item) {
  45.         super();
  46.         user = item.getEntityID();
  47.         jid = item.getName();
  48.         stamp = item.getNode();
  49.     }

  50.     /**
  51.      * Returns the bare JID of the user that was offline when the message was sent.
  52.      *
  53.      * @return the bare JID of the user that was offline when the message was sent.
  54.      */
  55.     public Jid getUser() {
  56.         return user;
  57.     }

  58.     /**
  59.      * Returns the full JID of the user that sent the message.
  60.      *
  61.      * @return the full JID of the user that sent the message.
  62.      */
  63.     public String getJid() {
  64.         return jid;
  65.     }

  66.     /**
  67.      * Returns the stamp that uniquely identifies the offline message. This stamp will
  68.      * be used for getting the specific message or delete it. The stamp may be of the
  69.      * form UTC timestamps but it is not required to have that format.
  70.      *
  71.      * @return the stamp that uniquely identifies the offline message.
  72.      */
  73.     public String getStamp() {
  74.         return stamp;
  75.     }
  76. }