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
022/**
023 * The OfflineMessageHeader holds header information of an offline message. The header
024 * information was retrieved using the {@link OfflineMessageManager} class.<p>
025 *
026 * Each offline message is identified by the target user of the offline message and a unique stamp.
027 * Use {@link OfflineMessageManager#getMessages(java.util.List)} to retrieve the whole message.
028 *
029 * @author Gaston Dombiak
030 */
031public class OfflineMessageHeader {
032    /**
033     * Bare JID of the user that was offline when the message was sent.
034     */
035    private String user;
036    /**
037     * Full JID of the user that sent the message.
038     */
039    private String jid;
040    /**
041     * Stamp that uniquely identifies the offline message. This stamp will be used for
042     * getting the specific message or delete it. The stamp may be of the form UTC timestamps
043     * but it is not required to have that format.
044     */
045    private String stamp;
046
047    public OfflineMessageHeader(DiscoverItems.Item item) {
048        super();
049        user = item.getEntityID();
050        jid = item.getName();
051        stamp = item.getNode();
052    }
053
054    /**
055     * Returns the bare JID of the user that was offline when the message was sent.
056     *
057     * @return the bare JID of the user that was offline when the message was sent.
058     */
059    public String getUser() {
060        return user;
061    }
062
063    /**
064     * Returns the full JID of the user that sent the message.
065     *
066     * @return the full JID of the user that sent the message.
067     */
068    public String getJid() {
069        return jid;
070    }
071
072    /**
073     * Returns the stamp that uniquely identifies the offline message. This stamp will
074     * be used for getting the specific message or delete it. The stamp may be of the
075     * form UTC timestamps but it is not required to have that format.
076     *
077     * @return the stamp that uniquely identifies the offline message.
078     */
079    public String getStamp() {
080        return stamp;
081    }
082}