package mfl;

public class String
extends mfl.Value
{
  java.lang.String java_value;

  public String(){
    java_value = "";
  }
  public String(java.lang.String v){
    java_value = v;
  }

  public mfl.Value count_op()
    {return new mfl.Integer(java_value.length());}

  public boolean equals(Object x)
   {if (!(x instanceof String)) return false;
    return java_value.compareTo(((String)x).java_value) == 0;}

  public mfl.Value greater_than_op(mfl.Value x)
    {if (!(x instanceof String)) return super.greater_than_op(x);
    return java_value.compareTo(((String)x).java_value) > 0 ? mfl.Boolean.True : mfl.Boolean.False;}

  public mfl.Value greater_than_or_equal_op(mfl.Value x)
    {if (!(x instanceof String)) return super.greater_than_or_equal_op(x);
    return java_value.compareTo(((String)x).java_value) >= 0 ? mfl.Boolean.True : mfl.Boolean.False;}

  public int hashCode()
    {return java_value.hashCode();}

  public mfl.Value index_op(mfl.Value x)
    {char [] str = {' '};
    if (!(x instanceof mfl.Integer)) return super.index_op(x);
    if (((mfl.Integer)x).java_value < 1) return super.index_op(x);
    if (((mfl.Integer)x).java_value > java_value.length()) return super.index_op(x);
    str[0] = java_value.charAt((int)(((mfl.Integer)x).java_value-1));
    return new String(new java.lang.String(str));}

  public mfl.Value index_op(mfl.Value x, mfl.Value y)
    {int i, j;
    if (!(x instanceof mfl.Integer)) return super.index_op(x, y);
    if (!(y instanceof mfl.Integer)) return super.index_op(x, y);
    i = (int)((mfl.Integer)x).java_value; j = (int)((mfl.Integer)y).java_value;
    if (i < 1) return super.index_op(x, y);
    if (i > java_value.length()) return super.index_op(x, y);
    if (j < i) return super.index_op(x, y);
    if (j > java_value.length()) j = java_value.length();
    return new String(java_value.substring(i-1, j));}
    
  public mfl.Value less_than_op(mfl.Value x)
    {if (!(x instanceof String)) return super.less_than_op(x);
    return java_value.compareTo(((String)x).java_value) < 0 ? mfl.Boolean.True : mfl.Boolean.False;}

  public mfl.Value less_than_or_equal_op(mfl.Value x)
    {if (!(x instanceof String)) return super.less_than_or_equal_op(x);
    return java_value.compareTo(((String)x).java_value) <= 0 ? mfl.Boolean.True : mfl.Boolean.False;}

  public mfl.Value not_equal_op(mfl.Value x)
    {if (!(x instanceof String)) return super.not_equal_op(x);
    return java_value.compareTo(((String)x).java_value) != 0 ? mfl.Boolean.True : mfl.Boolean.False;}

  public mfl.Value plus_op(mfl.Value x)
    {if (!(x instanceof String)) return super.plus_op(x);
    return new String(java_value + ((String)x).java_value);}

  public java.lang.String toString()
    {return java_value;}

}

