PacketFactory.java 2.09 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
/**
 * $RCSfile$
 * $Revision$
 * $Date$
Matt Tucker's avatar
Matt Tucker committed
5
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
Matt Tucker's avatar
Matt Tucker committed
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
package org.jivesoftware.messenger;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

/**
 * A factory to produce packets in one of the three XMPP flavors:
 * iq, presence, or message.
 *
 * @author Iain Shigeoka
 */
public interface PacketFactory {

    /**
     * Create an empty message.
     *
     * @return an empty message packet.
     */
    Message getMessage();

    /**
     * Create a message parsed from the given stream.
     *
     * @param xpp the stream reader.
     * @return a message produced from the reader.
     * @throws XMLStreamException if there was trouble reading the stream.
     */
    Message getMessage(XMLStreamReader xpp) throws XMLStreamException;

    /**
     * Create a message with the given body text.
     *
     * @param msgText the message body text.
     * @return a message with body text.
     * @throws XMLStreamException if there was trouble reading the stream.
     */
    Message getMessage(String msgText) throws XMLStreamException;

    /**
     * Create an empty iq packet.
     *
     * @return an empty iq packet.
     */
    IQ getIQ();

    /**
     * Create an IQ packet from the given stream.
     *
     * @param xpp the stream to read the iq packet from.
     * @return the iq packet created.
     * @throws XMLStreamException if there was trouble reading the stream.
     */
    IQ getIQ(XMLStreamReader xpp) throws XMLStreamException;

    /**
     * Create an empty presence packet.
     *
     * @return an empty presence packet.
     */
    Presence getPresence();

    /**
     * Create a presence packet from the given stream.
     *
     * @param xpp the stream to read the presence packet from.
     * @return the packet created.
     * @throws XMLStreamException if there was trouble reading the stream.
     */
    Presence getPresence(XMLStreamReader xpp) throws XMLStreamException;
}