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

/**
 * This is the class for character constants.
 *
 * @version     Last modified on Tue Jan 21 08:05:40 2014 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;

public class CharConstant extends Constant
  {
    /**
     * Constructs a new <tt>CharConstant</tt> with the given value.
     */
    public CharConstant (char value)
    {
      _sort = Taxonomy.CHAR;
      _value = value;
    }

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

    /**
     * Return the char value of this <tt>CharConstant</tt>.
     */
    public char value ()
    {
      return _value;
    }

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

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

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

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

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

  }