Java Code Examples for org.apache.jena.sparql.syntax.Element#visit()
The following examples show how to use
org.apache.jena.sparql.syntax.Element#visit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutputClauseNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementTGroup el) { List<Element> nzed = new ArrayList<>(); for (Element e : el.getTExpressions()) { e.visit(this); nzed.add(result); } result = new ElementTGroup(nzed, el.isDistinct(), el.getSeparator()); }
Example 2
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementGroup group) { ElementGroup ret = new ElementGroup(); for (Element elt: group.getElements() ) { elt.visit(this); ret.addElement(result); } result = ret; }
Example 3
Source File: SPARQLExtQuerySerializer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visitBindingClauses(SPARQLExtQuery query) { if (query.getBindingClauses() == null) { return; } for (Element iteratorOrSource : query.getBindingClauses()) { iteratorOrSource.visit(fmtElement); out.newline(); } }
Example 4
Source File: SPARQLExtFmtExprSPARQL.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ExprFunctionOp funcOp) { String fn = funcOp.getFunctionPrintName(context); if (funcOp instanceof E_NotExists) { fn = "NOT EXISTS"; } else if (funcOp instanceof E_Exists) { fn = "EXISTS"; } else { throw new ARQInternalErrorException("Unrecognized ExprFunctionOp: " + fn); } SPARQLExtFormatterElement fmtElt = new SPARQLExtFormatterElement(out, context); out.print(fn); out.print(" "); int indent = out.getAbsoluteIndent(); int currentCol = out.getCol(); try { out.setAbsoluteIndent(currentCol); Element el = funcOp.getElement(); if (el == null) { el = OpAsQuery.asQuery(funcOp.getGraphPattern()).getQueryPattern(); } el.visit(fmtElt); } finally { out.setAbsoluteIndent(indent); } }
Example 5
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementNotExists notExists) { Element arg = notExists.getElement(); arg.visit(this); result = new ElementNotExists(result); }
Example 6
Source File: SPARQLExtFormatterElement.java From sparql-generate with Apache License 2.0 | 5 votes |
public void visitAsGroup(Element el) { boolean needBraces = !((el instanceof ElementGroup) || (el instanceof ElementSubQuery)); if (needBraces) { out.print("{ "); out.incIndent(INDENT); } el.visit(this); if (needBraces) { out.decIndent(INDENT); out.print("}"); } }
Example 7
Source File: QueryXExprNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
private List<Element> normalizeOutput(List<Element> elements, NodeExprNormalizer nenzer) { final OutputClauseNormalizer nzer = new OutputClauseNormalizer(nenzer); final List<Element> group = new ArrayList<>(); for (Element el : elements) { el.visit(nzer); group.add(nzer.getResult()); } return group; }
Example 8
Source File: OutputClauseNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementFormat el) { visit(el.getExpr()); final ElementExpr expr = (ElementExpr) result; List<Element> nzed = new ArrayList<>(); for (Element e : el.getTExpressions()) { e.visit(this); nzed.add(result); } result = new ElementFormat(expr, nzed); }
Example 9
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementOptional opt) { Element elt = opt.getOptionalElement(); elt.visit(this); result = new ElementOptional(result); }
Example 10
Source File: QueryPatternNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementUnion el) { final ElementUnion res = new ElementUnion(); for (final Element element : el.getElements()) { element.visit(this); res.addElement(result); } result = res; }
Example 11
Source File: QueryPatternNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementGroup el) { final ElementGroup res = new ElementGroup(); for (final Element element : el.getElements()) { element.visit(this); res.addElement(result); } result = res; }
Example 12
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementUnion union) { ElementUnion ret = new ElementUnion(); for (Element elt: union.getElements()) { elt.visit(this); ret.addElement(result); } result = ret; }
Example 13
Source File: OutputClauseNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementTGroup el) { for (Element e : el.getTExpressions()) { e.visit(this); } result = el; }
Example 14
Source File: OutputClauseNormalizer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visit(ElementFormat el) { visit(el.getExpr()); for (Element e : el.getTExpressions()) { e.visit(this); } result = el; }
Example 15
Source File: FindAllVariables.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementGroup e) { for (Element ge : e.getElements()) { ge.visit(this); } }
Example 16
Source File: TriplePatternExtractor.java From NLIWOD with GNU Affero General Public License v3.0 | 5 votes |
@Override public void visit(final ElementUnion el) { unionCount++; for (Element e : el.getElements()) { e.visit(this); } }
Example 17
Source File: TriplePatternExtractor.java From NLIWOD with GNU Affero General Public License v3.0 | 4 votes |
@Override public void visit(final ElementGroup el) { for (Element e : el.getElements()) { e.visit(this); } }
Example 18
Source File: SPARQLExtFormatterElement.java From sparql-generate with Apache License 2.0 | 4 votes |
@Override public void visit(ElementGroup el) { out.print("{"); int initialRowNumber = out.getRow(); out.incIndent(INDENT); if (!GROUP_FIRST_ON_SAME_LINE) { out.newline(); } int row1 = out.getRow(); out.pad(); boolean first = true; Element lastElt = null; for (Element subElement : el.getElements()) { // Some adjacent elements need a DOT: // ElementTriplesBlock, ElementPathBlock if (!first) { // Need to move on after the last thing printed. // Check for necessary DOT as separator if (GROUP_SEP_DOT || needsDotSeparator(lastElt, subElement)) { out.print(" . "); } out.newline(); } subElement.visit(this); first = false; lastElt = subElement; } out.decIndent(INDENT); // Where to put the closing "}" int row2 = out.getRow(); if (row1 != row2) { out.newline(); } // Finally, close the group. if (out.getRow() == initialRowNumber) { out.print(" "); } out.print("}"); }
Example 19
Source File: FindAllVariables.java From quetzal with Eclipse Public License 2.0 | 4 votes |
@Override public void visit(ElementUnion e) { for (Element ge : e.getElements()) { ge.visit(this); } }
Example 20
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 4 votes |
@Override public void visit(ElementExists exists) { Element arg = exists.getElement(); arg.visit(this); result = new ElementExists(result); }