code: protected String getQueryString() {
          if (bindings.size() == 0)
              return queryString;
          String qry = queryString;
          int b = qry.indexOf('{');
          String select = qry.substring(0, b);
          String where = qry.substring(b);
          for (String name : bindings.getBindingNames()) {
              String replacement = getReplacement(bindings.getValue(name));
              if (replacement != null) {
                  String pattern = "[\\?\\$]" + name + "(?=\\W)";
                  select = select.replaceAll(pattern, "");
                  where = where.replaceAll(pattern, replacement);
              }
          }
          return select + where;
      }
docs: all code below is copy-pasted from org.eclipse.rdf4j.repository.sparql.query.SPARQLOperation