// $Id: Text.java,v 1.5 2004/02/27 16:30:00 m31 Exp $
//
// This file is part of the program suite "Principia Mathematica II"
// which is a working prototype for the main project:
// "Hilbert II" - http://www.qedeq.org
//
// Copyright 2001-2004  Michael Meyling <mime@qedeq.org>.
//
// "Principia Mathematica II" is free software; you can redistribute
// it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

package com.meyling.principia.argument;


import com.meyling.principia.io.Utility;


/**
 * An object of this class represents a text string.
 *
 * @version $Revision: 1.5 $
 * @author  Michael Meyling
 */
public class Text extends AbstractArgumentAtom implements Argument {

    /** the plain text */
    private final String text;


    /**
     * Constructs a <code>Text</code>.
     *
     * @param   text    text string
     * @throws  IllegalArgumentException    if <code>text</code> was a nullpointer
     */
    public Text(final String text) {
        if (text == null) {
            throw new IllegalArgumentException(
                ArgumentConstants.NULLPOINTER_PARAMETER);
        }
        this.text = text;
    }


    /**
     * Get the text.
     *
     * @return  text
     */
    public final String getText() {
        return text;
    }


    /** @inherited */
    public final boolean equals(Object object) {
        if (object instanceof Text) {
            return ((Text) object).text.equals(text);
        } else {
            return false;
        }
    }


    /** @inherited */
    public final Argument copy() {
        return this;
        // no deep necessary as long there could no modifications be done
        // if this changes, the following line should be used:
        // return new Text(text);
    }


    /** @inherited */
    public final String toString() {
        return Utility.quote(text);
    }


}
