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


/**
 * StartOfAuthority record marks the start of a zone of authority.
 */
public class StartOfAuthority
        extends DnsRecord {
    private String origin;
    private String mailAddress;
    private long serial;
    private long refresh;
    private long retry;
    private long expire;
    private long ttl;

    protected void decode(DnsInputStream inputStream)
            throws IOException {
        origin = inputStream.readDomainName();
        mailAddress = inputStream.readDomainName();
        serial = inputStream.readInt();
        refresh = inputStream.readInt();
        retry = inputStream.readInt();
        expire = inputStream.readInt();
        ttl = inputStream.readInt();
    }

    /**
     * Gets domain-name of the name server that was the original or primary source
     * of data for this zone.
     *
     * @return origin
     */
    public String getOrigin() {
        return origin;
    }

    /**
     * Gets e-mail address of the person responsible for this zone.
     *
     * @return e-mail address
     */
    public String getMailAddress() {
        return mailAddress;
    }

    /**
     * Gets version number of the orignal copy of the zone.
     *
     * @return version number
     */
    public long getSerial() {
        return serial;
    }

    /**
     * Gets time interval before the zone should be refreshed.
     *
     * @return refresh interval
     */
    public long getRefresh() {
        return refresh;
    }

    /**
     * Gets retry interval for a failed refresh.
     *
     * @return retry interval
     */
    public long getRetry() {
        return retry;
    }

    /**
     * Gets time interval that can elapse before the zone is no longer authoritative.
     *
     * @return time interval
     */
    public long getExpire() {
        return expire;
    }

    /**
     * Gets TTL (Time to Live) for resource records from this zone.
     *
     * @return time to live
     */
    public long getTTL() {
        return ttl;
    }

    /**
     * Gets String representation of this record.
     *
     * @return String
     */
    public String toString() {
        return getRecordName()
                + "\tstart of authority\n\torigin = " + origin
                + "\n\tmail address = " + mailAddress
                + "\n\tserial = " + serial
                + "\n\trefresh = " + refresh
                + "\n\tretry = " + retry
                + "\n\texpire = " + expire
                + "\n\tminimum TTL = " + ttl;
    }
}

