Пример #1
0
 /**
  * Fetches all elements of the optional, i.e., of the OPTIONAL clause. query
  *
  * @param query Input query
  * @return List of elements from the OPTIONAL clause if there is one, else null
  */
 private static List<Element> getOptionalElements(Query query) {
   ElementGroup elt = (ElementGroup) query.getQueryPattern();
   for (int i = 0; i < elt.getElements().size(); i++) {
     Element e = elt.getElements().get(i);
     if (e instanceof ElementOptional) {
       return ((ElementGroup) ((ElementOptional) e).getOptionalElement()).getElements();
     }
   }
   return new ArrayList<Element>();
 }
Пример #2
0
 /**
  * Fetches all elements of the query body, i.e., of the WHERE clause of a query
  *
  * @param query Input query
  * @return List of elements from the WHERE clause
  */
 private static List<Element> getWhereElements(Query query) {
   List<Element> result = new ArrayList<Element>();
   ElementGroup elt = (ElementGroup) query.getQueryPattern();
   for (int i = 0; i < elt.getElements().size(); i++) {
     Element e = elt.getElements().get(i);
     if (!(e instanceof ElementOptional)) {
       result.add(e);
     }
   }
   return result;
 }
Пример #3
0
 /* @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);
   }
 }