// FILE. . . . . /home/hak/hlt/src/hlt/osfv3/base/StringConstant.java
// EDIT BY . . . Hassan Ait-Kaci
// ON MACHINE. . Hak-Laptop
// STARTED ON. . Mon Sep 02 16:47:11 2013

/**
 * @version     Last modified on Fri Aug 23 12:10:32 2019 by hak
 * @author      <a href="mailto:hak@acm.org">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; <a href="http://www.hassan-ait-kaci.net/">by the author</a>
 */

package hlt.osf.base;

import hlt.osf.exec.Taxonomy;

/**
 * This is the class for string constants.
 */
public class StringConstant extends Constant
  {
    /**
     * Constructs a new <tt>StringConstant</tt> with the given value.
     */
    public StringConstant (String value)
    {
      _sort = Taxonomy.STRING;
      _value = value.intern();
    }

    /**
     * The value if this constant.
     */
    private String _value;

    /**
     * Return the string value of this <tt>StringConstant</tt>.
     */
    public String value ()
    {
      return _value;
    }

    /**
     * Returns <tt>true</tt> iff the specified object is an
     * <tt>StringConstant</tt> carrying the same value as this one.
     */
    public boolean equals (Object other)
    {
      if (!(other instanceof StringConstant))
	return false;

      return _value == ((StringConstant)other).value();
    }

    /**
     * Returns a <tt>String</tt> representation of this
     * <tt>StringConstant</tt>.
     */
    public String toString ()
    {
      return _value;
    }

    /**
     * Returns a <tt>String</tt> representation of this
     * <tt>StringConstant</tt> between double quotes.
     */
    public String toQuotedString ()
    {
      return "\""+_value+"\"";
    }

    public String displayForm ()
    {
      return toQuotedString();
    }

  }
