/* 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/>
 * Message Expiration.
 * </p>
 *
 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a>
 * @version Revision: 1.1 Date: 2002-11-12 11:36:17
 */

public class Expiration {

    private long expiration = 0;

    /**
     * Default Constructor
     */
    public Expiration() {
    }

    /**
     * Create Expiration with time to live.
     *
     * @param expiration
     */
    public Expiration(long expiration) throws JMSException {
        if(expiration >= 0) {
            this.expiration = expiration;
        }
        else {
            throw new JMSException("Illegal Message Expiration.");
        }
    }

    /**
     * Get message expiration.
     *
     * @return expiration
     */
    public long getExpiration() {
        return this.expiration;
    }

    public String toString() {
        return "Expiration value : " + String.valueOf(this.expiration);
    }
}
