/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.jms.message;

import javax.jms.JMSException;

/**
 * <p/>
 * This class implements message header fields CorrelationID for messages.
 * </p>
 *
 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a>
 * @version Revision: 1.1 Date: 2002-11-10 19:52:20
 */

public class CorrelationID {

    private String stringID = "";
    private byte[] bytesID = null;

    /**
     * Default Constructor.
     */
    public CorrelationID() {
    }

    /**
     * Create CorrelationID with string ID.
     *
     * @param correlationID String type.
     * @throws javax.jms.JMSException if the JMS provider fails to set the correlation ID due
     *                                to some internal error.
     */
    public CorrelationID(String correlationID) throws JMSException {
        this.stringID = correlationID;
    }

    /**
     * Create CorrelationID with bytes ID.
     *
     * @param correlationID Bytes type.
     * @throws javax.jms.JMSException if the JMS provider fails to set the correlation ID due
     *                                to some internal error.
     */
    public CorrelationID(byte[] correlationID) throws JMSException {
        this.bytesID = correlationID;
    }

    /**
     * Gets the String correlation ID for the message.
     *
     * @return correlationID String type.
     * @throws javax.jms.JMSException if the JMS provider fails to set the correlation ID due
     *                                to some internal error.
     */
    public String getStringID() throws JMSException {
        return this.stringID;
    }

    /**
     * Gets the byte correlation ID for the message.
     *
     * @return correlationID Bytes type.
     * @throws javax.jms.JMSException if the JMS provider fails to set the correlation ID due
     *                                to some internal error.
     */
    public byte[] getBytesID() throws JMSException {
        return this.bytesID;
    }

    public String toString() {
        return "CorelationID " + stringID;
    }
}
