/*
 * @(#)MailInfo.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.dns.record;


import com.jscape.inet.dns.DnsInputStream;

import java.io.IOException;
import java.io.Serializable;


/**
 * MailInfo record represents a mailbox or mail list information.
 * Experimental per RFC 1035
 */
public class MailInfo
        extends DnsRecord
        implements Serializable {
    private String responsibleBox;
    private String errorBox;

    protected void decode(DnsInputStream inputStream)
            throws IOException {
        responsibleBox = inputStream.readDomainName();
        errorBox = inputStream.readDomainName();
    }

    /**
     * Gets responsible mailbox.
     * A domain-name which specifies a mailbox which is responsible for the mailing
     * list or mailbox.  If this domain name names the root, the owner of the MailInfo
     * RR is responsible for itself.  Note that many existing mailing lists use a
     * mailbox X-request for the ResponsibleMailBox field of  mailing list X, e.g.,
     * Msgroup-request for Msgroup.  This field provides a more general mechanism.
     *
     * @return responsible mailbox
     */
    public String getResponsibleMailbox() {
        return responsibleBox;
    }

    /**
     * Gets error mailbox.
     * A domain-name which specifies a mailbox which is to receive error messages
     * related to the mailing list or mailbox specified by the owner of the MailInfo
     * RR (similar to the ERRORS-TO: field which has been proposed).  If this
     * domain name names the root, errors should be returned to the sender of the
     * message.
     *
     * @return error mailbox
     */
    public String getErrorMailbox() {
        return errorBox;
    }

    /**
     * Gets String representation of this record.
     *
     * @return String
     */
    public String toString() {
        return getRecordName() + "\tresponsible mailbox = " + responsibleBox + ", error mailbox = " + errorBox;
    }
}

