/* @see org.mindswap.common.Parser#parse(java.lang.Object) */ public ABoxQuery<Variable> parse(final String queryString) throws ParseException { if (queryString == null) throw new ParseException(queryString, "Query string null."); final Query query; try { switch (lang) { case RDQL: query = QueryFactory.create(queryString, Syntax.syntaxRDQL); break; case SPARQL_DL: case SPARQL: default: query = QueryFactory.create(queryString, Syntax.syntaxSPARQL); break; } } catch (final QueryException e) { throw new ParseException(queryString, e); } final ISWRLFactory swrlFactory = SWRLFactory.createFactory(model); final Map<String, Variable> vars = new HashMap<String, Variable>(); final Element elmnt = query.getQueryPattern(); final ElementVisitor v = new ElementVisitor(model, swrlFactory, vars); elmnt.visit(v); final OWLList<Atom> atomList = v.getAtomList(); final List<Variable> resultVars = new ArrayList<Variable>(); for (final String var : query.getResultVars()) { resultVars.add(vars.get("?" + var)); } return new ABoxQuery<Variable>(atomList, resultVars); }
/* @see com.hp.hpl.jena.sparql.syntax.ElementVisitorBase#visit(com.hp.hpl.jena.sparql.syntax.ElementGroup) */ @Override public void visit(final ElementGroup elementgroup) { for (final Element e : elementgroup.getElements()) { e.visit(this); } }