code: public static int toIntValue(Object o) throws PageException {
  
  	if (o instanceof Number) return ((Number) o).intValue();
  	else if (o instanceof Boolean) return ((Boolean) o).booleanValue() ? 1 : 0;
  	else if (o instanceof CharSequence) return toIntValue(o.toString().trim());
  	else if (o instanceof Character) return (int) (((Character) o).charValue());
  	// else if(o instanceof Clob) return toIntValue(toString(o));
  	else if (o instanceof Castable) return (int) ((Castable) o).castToDoubleValue();
  	else if (o instanceof Date) return (int) new DateTimeImpl((Date) o).castToDoubleValue();
  
  	if (o instanceof String) throw new ExpressionException("Can't cast String [" + CasterException.crop(o) + "] to a number");
  	else if (o instanceof ObjectWrap) return toIntValue(((ObjectWrap) o).getEmbededObject());
  
  	throw new CasterException(o, "number");
      }
docs: cast a Object to a int value (primitive value type)
  
  @param o Object to cast
  @return casted int value
  @throws PageException