001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smackx.offline;
019
020import org.jivesoftware.smackx.disco.packet.DiscoverItems;
021
022import org.jxmpp.jid.Jid;
023
024/**
025 * The OfflineMessageHeader holds header information of an offline message. The header
026 * information was retrieved using the {@link OfflineMessageManager} class.<p>
027 *
028 * Each offline message is identified by the target user of the offline message and a unique stamp.
029 * Use {@link OfflineMessageManager#getMessages(java.util.List)} to retrieve the whole message.
030 *
031 * @author Gaston Dombiak
032 */
033public class OfflineMessageHeader {
034    /**
035     * Bare JID of the user that was offline when the message was sent.
036     */
037    private Jid user;
038    /**
039     * Full JID of the user that sent the message.
040     */
041    private String jid;
042    /**
043     * Stamp that uniquely identifies the offline message. This stamp will be used for
044     * getting the specific message or delete it. The stamp may be of the form UTC timestamps
045     * but it is not required to have that format.
046     */
047    private String stamp;
048
049    public OfflineMessageHeader(DiscoverItems.Item item) {
050        super();
051        user = item.getEntityID();
052        jid = item.getName();
053        stamp = item.getNode();
054    }
055
056    /**
057     * Returns the bare JID of the user that was offline when the message was sent.
058     *
059     * @return the bare JID of the user that was offline when the message was sent.
060     */
061    public Jid getUser() {
062        return user;
063    }
064
065    /**
066     * Returns the full JID of the user that sent the message.
067     *
068     * @return the full JID of the user that sent the message.
069     */
070    public String getJid() {
071        return jid;
072    }
073
074    /**
075     * Returns the stamp that uniquely identifies the offline message. This stamp will
076     * be used for getting the specific message or delete it. The stamp may be of the
077     * form UTC timestamps but it is not required to have that format.
078     *
079     * @return the stamp that uniquely identifies the offline message.
080     */
081    public String getStamp() {
082        return stamp;
083    }
084}