QueryManager { protected static Set<String> findQueryPrefixes(String queryString) { HashSet<String> res = new HashSet<>(); Scanner sc = new Scanner(queryString); while (true) { while (sc.findInLine(prefixPattern) != null) { MatchResult m = sc.match(); res.add(m.group(1)); } if (!sc.hasNextLine()) { break; } sc.nextLine(); } sc.close(); return res; } QueryManager(); void init(FedXRepository repo, FederationContext federationContext); void shutdown(); void registerQuery(QueryInfo queryInfo); Set<QueryInfo> getRunningQueries(); int getNumberOfRunningQueries(); void abortQuery(QueryInfo queryInfo); void finishQuery(QueryInfo queryInfo); boolean isRunning(QueryInfo queryInfo); void addPrefixDeclaration(String prefix, String namespace); TupleQuery prepareTupleQuery(String queryString); GraphQuery prepareGraphQuery(String queryString); BooleanQuery prepareBooleanQuery(String queryString); Query prepareQuery(String queryString); String getQueryPlan(String queryString); BigInteger getNextQueryId();  }
@Test public void testPrefix3() { String queryString = "PREFIX rdf: <http: Set<String> prefixes = QueryManager.findQueryPrefixes(queryString); Assertions.assertTrue(prefixes.size() == 1); Assertions.assertTrue(prefixes.contains("rdf")); }
@Test public void testPrefix4() { String queryString = "PREFIX rdf: <http: Set<String> prefixes = QueryManager.findQueryPrefixes(queryString); Assertions.assertTrue(prefixes.size() == 2); Assertions.assertTrue(prefixes.contains("rdf")); Assertions.assertTrue(prefixes.contains("foaf")); }
@Test public void testPrefix5() { String queryString = "PREFIX rdf: <http: Set<String> prefixes = QueryManager.findQueryPrefixes(queryString); Assertions.assertTrue(prefixes.size() == 2); Assertions.assertTrue(prefixes.contains("rdf")); Assertions.assertTrue(prefixes.contains("foaf")); }