//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

package ilog.language.design.kernel;

/**
 * @version     Last modified on Sun Sep 15 17:37:38 2002 by hak
 * @version          modified on Wed Jul 24 12:18:53 2002 by pviry
 * @author      <a href="mailto:hak@ilog.fr">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; 2000-2002 <a href="http://www.ilog.fr/">ILOG, S.A.</a>
 */

import ilog.language.design.types.*;
import ilog.language.design.base.*;

/**
 * This is the class of boxed integers.
 */
public class Int extends Constant
{
  private int _value;

  public Int (int value, boolean flag)
    {
      if (flag)
        _type = Type.INT;
      else
        _type = Type.INT();      
      _setValue(value);
    }

  public Int (int value)
    {
      super(Type.INT());
      _setValue(value);
    }

  public final int value ()
    {
      return _value;
    }

  private final void _setValue (int value)
    {
      _value = value;
      if (value == 0) setIsNull();
    }

  public final void compile (Compiler compiler)
    {
      compiler.generate(new PushValueInt(_value));
    }

  public final boolean equals (Object other)
    {
      if (!(other instanceof Int))
        return false;
      
      return _value == ((Int)other).value();
    }

  public final String toString ()
    {
      return String.valueOf(_value);
      //      return "<"+_value+">";
    }

  // Added by PV
  public final String toTypedString ()
    {
      return typed(String.valueOf(_value));
    }
}
