/*
 * @(#)NntpArticle.java
 *
 * Copyright (c) 2001-2002 JScape
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JScape. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JScape.
 */
package com.jscape.inet.nntp;

import com.jscape.inet.mime.MimeException;


/**
 * Represents article header and body. This class extends MimeMessage and can
 * be constructed using the default constructor or from existing Mime
 * contents.
 *
 * @see com.jscape.inet.mime.MimeMessage
 */
public class NntpArticle
        extends NntpArticleHeader {
    /**
     * Constructs a new <code>NntpArticle</code>.
     */
    public NntpArticle() {
        super();
    }

    /**
     * Constructs a new <code>NntpArticle</code>. Article is constructed with
     * provided From, Newsgroups and Subject headers.
     *
     * @param from       the email address of the person responsible for this article
     * @param newsgroups a comma delimited list of newsgroups
     * @param subject    the subject of the article
     *
     * @throws MimeException if a MIME related error occurs
     * @see com.jscape.inet.mime.MimeException
     */
    public NntpArticle(String from, String newsgroups, String subject)
            throws MimeException {
        this();
        setFrom(from);
        setNewsgroups(newsgroups);
        setSubject(subject);
    }

    /**
     * Constructs a new <code>NntpArticle</code> from existing MIME content.
     *
     * @param contents the contents of mime message
     *
     * @throws MimeException if a MIME related error occurs
     * @see com.jscape.inet.mime.MimeException
     */
    public NntpArticle(byte[] contents)
            throws MimeException {
        super(contents);
    }

    /**
     * Sets From header for this <code>NntpArticle</code>.
     *
     * @param from the email address of the person responsible for this article
     *
     * @throws MimeException if a MIME related error occurs
     * @see com.jscape.inet.mime.MimeException
     */
    public void setFrom(String from)
            throws MimeException {
        addHeader("From", from);
    }

    /**
     * Sets Newsgroups header for this <code>NntpArticle</code>.
     *
     * @param newsgroups a comma delimited list of newsgroups
     *
     * @throws MimeException if a MIME related error occurs
     * @see com.jscape.inet.mime.MimeException
     */
    public void setNewsgroups(String newsgroups)
            throws MimeException {
        addHeader("Newsgroups", newsgroups);
    }

    /**
     * Sets Subject header for this <code>NntpArticle</code>.
     *
     * @param subject the subject of the article
     *
     * @throws MimeException if a MIME related error occurs
     * @see com.jscape.inet.mime.MimeException
     */
    public void setSubject(String subject)
            throws MimeException {
        addHeader("Subject", subject);
    }
}
