### Question:
AbstractQueryImpl implements SPARQLQuery { static String normalize(String query, Map<String, NODE> bindings, List<NODE> nodes, boolean createAliases) { String queryLower = query.toLowerCase(Locale.ENGLISH); Matcher matcher = VARIABLE.matcher(query); StringBuffer buffer = new StringBuffer(); while (matcher.find()) { String variable = matcher.group().substring(1); String replacement = matcher.group(); boolean unquoted = isUnquoted(queryLower, matcher); if (bindings.containsKey(variable)) { NODE node = bindings.get(variable); nodes.add(node); if (node.isResource()) { replacement = unquoted ? "iri(??)" : "`iri(??)`"; } else { replacement = unquoted ? "bif:__rdf_long_from_batch_params(??,??,??)" : "`bif:__rdf_long_from_batch_params(??,??,??)`"; } if (createAliases && !queryLower.substring(0, matcher.start()).contains("where") && !queryLower.substring(0, matcher.start()).contains("from")) { replacement = replacement + " as ?" + variable; } } matcher.appendReplacement(buffer, replacement); } matcher.appendTail(buffer); return buffer.toString(); } AbstractQueryImpl(Connection connection, int prefetch, String query); @Override final void setBinding(String variable, NODE node); @Override final void setMaxQueryTime(int secs); static void close(@Nullable Statement stmt, @Nullable ResultSet rs);  }### Answer:
@Test public void Normalize() { String queryString = "SELECT * WHERE {\n" + "?dimensionType ?_c2 ?_c3 ; ?_c4 ?dimensionTypeName .\n" + "?dimension ?_c7 ?dimensionType ; ?_c4 ?dimensionName .\n" + "OPTIONAL {?dimension ?_c9 ?dimensionDescription }\n" + "OPTIONAL {?dimension ?_c11 ?parent }\n" + "}\n" + "ORDER BY ?dimensionName"; Map<String, NODE> bindings = new HashMap<String, NODE>(); bindings.put("_c9", DC.description); bindings.put("_c2", RDFS.subClassOf); bindings.put("_c11", SKOS.broader); bindings.put("_c7", RDF.type); bindings.put("_c4", DC.title); bindings.put("_c3", new UID(TEST.NS, "Dimension")); List<NODE> nodes = new ArrayList<NODE>(); String modifiedQuery = AbstractQueryImpl.normalize(queryString, bindings, nodes, true); System.err.println(modifiedQuery); assertEquals(bindings.get("_c2"), nodes.get(0)); assertEquals(bindings.get("_c3"), nodes.get(1)); assertEquals(bindings.get("_c4"), nodes.get(2)); assertEquals(bindings.get("_c7"), nodes.get(3)); assertEquals(bindings.get("_c4"), nodes.get(4)); assertEquals(bindings.get("_c9"), nodes.get(5)); assertEquals(bindings.get("_c11"), nodes.get(6)); }