/*
 * @(#)Text.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.util.Enumeration;
import java.util.Vector;


/**
 * Text record is used to hold descriptive text. The semantics of the text
 * depends on the domain where it is found.
 */
public class Text
        extends DnsRecord {
    private Vector texts = new Vector();

    protected void decode(DnsInputStream inputStream)
            throws IOException {
        String s;

        while ((s = inputStream.readString()) != null) {
            texts.addElement(s);
        }
    }

    /**
     * Gets descriptive texts for Dns record.
     *
     * @return texts
     */
    public Enumeration getTexts() {
        return texts.elements();
    }

    /**
     * Gets String representation of this record.
     *
     * @return String
     */
    public String toString() {
        StringBuffer result = new StringBuffer();

        for (int i = 0; i < texts.size(); ++i) {
            if (i > 0) {
                result.append("\n\t\t");
            }
            result.append(texts.elementAt(i));
        }
        return getRecordName() + "\ttext = " + result;
    }
}

