org.apache.jena.sparql.syntax.ElementUnion Java Examples

The following examples show how to use org.apache.jena.sparql.syntax.ElementUnion. 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: QueryPatternSimplification.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void visit(ElementUnion union) {
	// remove nested unions
	ElementUnion ret = new ElementUnion();
	for (Element elt : union.getElements()) {
		elt.visit(this);
		if (result instanceof ElementUnion) {
			ElementUnion nestedUnion = (ElementUnion) result;
			for (Element subelt: nestedUnion.getElements()) {
				assert !(subelt instanceof ElementUnion) : subelt +"\n"+ nestedUnion;
				ret.addElement(subelt);
			}
		} else {
			ret.addElement(result);
		}
	}
	
	
	if (ret.getElements().size() == 1) {
		result = ret.getElements().get(0);
	} else {
		result = ret;
	}
	
}
 
Example #2
Source File: PropertyPathRewrite.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void visit(P_Alt p) {
	p.getLeft().visit(this);
	Element left = result;
	if (left!=null) {
		p.getRight().visit(this);
		Element right = result;
		if (right!=null) {
			ElementUnion ret = new ElementUnion(left);
			ret.addElement(right);
			result = ret;
		} else {
			result = null;
		}
	} else {
		result = null;
	}
}
 
Example #3
Source File: TriplePatternExtractor.java    From NLIWOD with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void visit(final ElementUnion el) {
	unionCount++;
	for (Element e : el.getElements()) {
		e.visit(this);
	}
}
 
Example #4
Source File: QueryPatternNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
@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 #5
Source File: RuleSystemToUnionQuery.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visit(ElementUnion union) {
	ElementUnion ret = new ElementUnion();
	for (Element elt: union.getElements()) {
		elt.visit(this);
		ret.addElement(result);
	}
	result = ret;
	
}
 
Example #6
Source File: NormalizedOWLQLTbox.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
protected void addOnlyAboxTriples(ElementUnion patterns, List<Triple> triples){
	boolean isAbsentFromAbox = false;
	ElementTriplesBlock sp = new ElementTriplesBlock();
	for (Triple t : triples) {
		if (isTripleAbsentFromAbox(t)) {
			isAbsentFromAbox = true;
			break;
		}
		sp.addTriple(t);
	}
	if (!isAbsentFromAbox)
		patterns.addElement(sp);
}
 
Example #7
Source File: OutputClauseNormalizer.java    From sparql-generate with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(ElementUnion el) {
    LOG.warn("Should not reach this point");
}
 
Example #8
Source File: OutputClauseNormalizer.java    From sparql-generate with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(ElementUnion el) {
    LOG.warn("Should not reach this point");
}
 
Example #9
Source File: SPARQLExtElementVisitorBase.java    From sparql-generate with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(ElementUnion el) {
}
 
Example #10
Source File: SPARQLExtFormatterElement.java    From sparql-generate with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(ElementUnion el) {
    if (el.getElements().size() == 1) {
        // If this is an element of just one, just do it inplace
        // Can't happen from a parsed query.
        // Now can :-)

        // SPARQL 1.1 inline UNION.
        // Same as OPTIONAL, MINUS
        out.print("UNION");
        out.incIndent(INDENT);
        out.newline();
        visitAsGroup(el.getElements().get(0));
        out.decIndent(INDENT);
        return;
    }

    if (UNION_MARKERS) {
        out.print("{");
        out.newline();
        out.pad();
    }

    out.incIndent(INDENT);

    boolean first = true;
    for (Element subElement : el.getElements()) {
        if (!first) {
            out.decIndent(INDENT);
            out.newline();
            out.print("UNION");
            out.newline();
            out.incIndent(INDENT);
        }
        visitAsGroup(subElement);
        first = false;
    }

    out.decIndent(INDENT);

    if (UNION_MARKERS) {
        out.newline();
        out.print("}");
    }
}
 
Example #11
Source File: FindAllVariables.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void visit(ElementUnion e) {
	for (Element ge : e.getElements()) {
		ge.visit(this);
	}
}
 
Example #12
Source File: StatisticsVisitor.java    From IGUANA with GNU Affero General Public License v3.0 votes vote down vote up
public void startElement(ElementUnion el) {this.union=true;}