code: private static int extractLimit(String queryString) {
  	int limitIndex = queryString.lastIndexOf("limit");
  
  	if (limitIndex == -1) {
  	    limitIndex = queryString.lastIndexOf("LIMIT");
  	}
  
  	if (limitIndex == -1) {
  	    return limitIndex;
  	}
  
  	String limitValue = queryString.substring(limitIndex + 5);
  
  	return Integer.parseInt(limitValue.trim());
      }
docs: Extracts limit value from query string.
  
  @param queryString OQL query string.
  @return Value of 'limit' clause.