package tcra.exercises.resolve_random_access_capability_private;

import java.util.List;
import tcra.math.*;

public class ResolveRandomAccessCapability_PreInsertAssertion
       implements Assertion
{
   public ResolveRandomAccessCapability_PreInsertAssertion() {}
   
   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self  = (MathString<MathType>)t.get(0);
      MathInteger          lb_index = (MathInteger)t.get(2);
      
      return(lb_index.getValue() >= 1 &&
         lb_index.getValue() <= lb_self.length()+1);
   } // end check(List)

   public String toString()
   {
      return "1 &lt;= k &lt;= |S| + 1";
   } // end toString()
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self  = (MathString<MathType>)t.get(0);
      MathInteger          lb_index = (MathInteger)t.get(2);

      return("1 &lt;= " +lb_index.toHTMLString()+ " &lt;= |" +
            lb_self.toHTMLString()+ "| + 1");
   } // end toInstanceString(List)
} // end class
