public static String addThisTypeClause(String str){
  String varName=TYPE_CLASS_VAR_NAME;
  Pattern pattern=Pattern.compile("(?i)WHERE\\s*\\{");
  Matcher matcher=pattern.matcher(str);
  if (matcher.find()) {
    int index=matcher.end();
    StringBuilder sb=new StringBuilder(str);
    sb.insert(index," ?this a ?" + varName + " . ");
    return sb.toString();
  }
 else {
    throw new IllegalArgumentException("Malformed query: could not find start of WHERE clause");
  }
}

public static String addThisTypeClause ( String str ) { String varName = TYPE_CLASS_VAR_NAME ; Pattern pattern = Pattern . compile ( "(?i)WHERE\\s*\\{" ) ; Matcher matcher = pattern . matcher ( str ) ; if ( matcher . find ( ) ) { int index = matcher . end ( ) ; StringBuilder sb = new StringBuilder ( str ) ; sb . insert ( index , " ?this a ?" + varName + " . " ) ; return sb . toString ( ) ; } else { throw new IllegalArgumentException ( "Malformed query: could not find start of WHERE clause" ) ; } }
inserts a statement ? this a ? type_class . after the where { keyword . the current implementation is not 100 % correct - it is based on a simple regex matching and somebody could put a where { into a comment to break it .
