当前位置: 首页>>代码示例>>Java>>正文


Java Var类代码示例

本文整理汇总了Java中org.apache.jena.sparql.core.Var的典型用法代码示例。如果您正苦于以下问题:Java Var类的具体用法?Java Var怎么用?Java Var使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Var类属于org.apache.jena.sparql.core包,在下文中一共展示了Var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GroupCondition

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
public Rule GroupCondition() {
    return FirstOf(
            Sequence(Var(),
                    pushQuery(
                            ((SPARQLQuery) pop(1)).addQGroupBy((Var) pop()))),
            Sequence(BuiltInCall(),
                    pushQuery(
                            ((SPARQLQuery) pop(1))
                                    .addQGroupBy((Expr) pop()))),
            Sequence(FunctionCall(),
                    pushQuery(((SPARQLQuery) pop(1)).addQGroupBy((Expr) pop()))),
            Sequence(LPAR(), Expression(),
                    FirstOf(Sequence(AS(), Var(), RPAR(),
                            pushQuery(((SPARQLQuery) pop(2)).addQGroupBy((Var) pop(), (Expr) pop()))),
                            Sequence(RPAR(), pushQuery(((SPARQLQuery) pop(1)).addQGroupBy((Expr) pop()))))));

}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:18,代码来源:SPARQLParser.java

示例2: build

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
public void build() {
    for (Element element : clause.getElements()) {
        if (element instanceof ElementPathBlock) {
            ElementPathBlock e = (ElementPathBlock) element;
            for (TriplePath t : e.getPattern().getList()) {
                Node n = t.getObject();
                if (n instanceof Var) {
                    addVar((Var) n);
                }
                n = t.getSubject();
                if (n instanceof Var)
                    addVar((Var) n);

                n = t.getPredicate();
                if (n instanceof Var)
                    addVar((Var) n);
            }
        }
    }
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:21,代码来源:IFDecl.java

示例3: toEPLSchema

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
public String toEPLSchema(Set<Var> vars) {
    CreateSchemaClause schema = new CreateSchemaClause();
    schema.setSchemaName(getHead().getURI().replace(getHead().getNameSpace(), "")); //TODO
    schema.setInherits(new HashSet<String>(Arrays.asList(new String[]{"TEvent"})));
    List<SchemaColumnDesc> columns = new ArrayList<SchemaColumnDesc>();
    for (Var var : vars) {
        SchemaColumnDesc scd = new SchemaColumnDesc();
        scd.setArray(false);
        scd.setType("String");
        scd.setName(var.getName());
        columns.add(scd);
    }

    schema.setColumns(columns);
    StringWriter writer = new StringWriter();
    schema.toEPL(writer);

    return writer.toString();
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:20,代码来源:DLEventDecl.java

示例4: visitGroupBy

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public void visitGroupBy(Query query) {
    if (query.hasGroupBy() && !query.getGroupBy().isEmpty()) {
        // Can have an empty GROUP BY list if the grouping is implicit
        // by use of an aggregate in the SELECT clause.
        final VarExprList namedExprs = query.getGroupBy();
        final VarExprList newNamedExprs = new VarExprList();
        final ExprNormalizer enzer = new ExprNormalizer();
        for (Var var : namedExprs.getVars()) {
            if(namedExprs.hasExpr(var)) {
                final Expr nzed = enzer.normalize(namedExprs.getExpr(var));
                newNamedExprs.add(var, nzed);
            } else {
                newNamedExprs.add(var);
            }
        }
        namedExprs.clear();
        namedExprs.addAll(newNamedExprs);
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:21,代码来源:QueryNormalizer.java

示例5: visit

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public void visit(ElementData el) {
    final NodeExprNormalizer nenzer = new NodeExprNormalizer();
    final ElementData nzed = new ElementData();
    final List<Var> vars = el.getVars();
    vars.forEach((v) -> {
        nzed.add(v);
    });
    el.getRows().forEach((b) -> {
        final BindingHashMap binding = new BindingHashMap();
        vars.forEach((v) -> {
            final Node n = b.get(v);
            if (n != null) {
                n.visitWith(nenzer);
                binding.add(v, nenzer.getResult());
            }
            nzed.add(binding);
        });
    });
    endVisit(nzed, nenzer);
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:22,代码来源:ElementNormalizer.java

示例6: makeIteratorPlan

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
 * Makes the plan for a SPARQL SELECTOR clause.
 *
 * @param elementIterator the SPARQL SELECTOR
 * @return -
 */
static IteratorPlan makeIteratorPlan(
        final ElementIterator elementIterator)
        throws SPARQLGenerateException {
    Objects.requireNonNull(elementIterator, "The Iterator must not be null");

    Var var = elementIterator.getVar();
    Expr expr = elementIterator.getExpr();

    Objects.requireNonNull(var, "The variable of the Iterator must not be null");
    Objects.requireNonNull(expr, "The Expr in the iterator must not be null");
    checkIsTrue(expr.isFunction(), "Iterator should be a function:"
            + " <iri>(...) AS ?var");

    ExprFunction function = expr.getFunction();
    String iri = function.getFunctionIRI();

    IteratorFunctionFactory factory = sr.get(iri);
    if (factory == null) {
        throw new SPARQLGenerateException("Unknown Iterator Function: " + iri);
    }
    IteratorFunction iterator = factory.create(iri);
    ExprList exprList = new ExprList(function.getArgs());
    iterator.build(exprList);
    return new IteratorPlanImpl(iterator, exprList, var);
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:32,代码来源:PlanFactory.java

示例7: makeSourcePlan

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
 * Makes the plan for a SPARQL SOURCE clause. If (1) accept is not set and
 * (2) the {@code StreamManager} finds the file locally, then the behaviour
 * is not specified (yet).
 *
 * @param elementSource the SPARQL SOURCE
 * @return -
 */
private static SourcePlan makeSourcePlan(
        final ElementSource elementSource) throws SPARQLGenerateException {
    Objects.requireNonNull(elementSource, "The Source must not be null");

    Node node = elementSource.getSource();
    Node accept = elementSource.getAccept();
    Var var = elementSource.getVar();

    Objects.requireNonNull(node, "The source must not be null");
    checkIsTrue(node.isURI() || node.isVariable(), "The source must be a"
            + " URI or a variable. Got " + node);
    // accept may be null
    checkIsTrue(accept == null || accept.isVariable() || accept.isURI(),
            "The accept must be null, a variable or a URI. Got" + accept);
    Objects.requireNonNull(var, "The variable must not be null.");

    return new SourcePlanImpl(node, accept, var);
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:27,代码来源:PlanFactory.java

示例8: getActualSource

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
 *
 * @param binding -
 * @return the actual URI that represents the location of the query to be
 * fetched.
 */
private String getActualSource(
        final BindingHashMapOverwrite binding) {
    if (node.isVariable()) {
        Node actualSource = binding.get((Var) node);
        if (actualSource == null) {
            return null;
        }
        if (!actualSource.isURI()) {
            throw new SPARQLGenerateException("Variable " + node.getName()
                    + " must be bound to a IRI that represents the location"
                    + " of the query to be fetched.");
        }
        return actualSource.getURI();
    } else {
        if (!node.isURI()) {
            throw new SPARQLGenerateException("The source must be a IRI"
                    + " that represents the location of the query to be"
                    + " fetched. Got " + node.getURI());
        }
        return node.getURI();
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:29,代码来源:SourcePlanImpl.java

示例9: BindingHashMapOverwrite

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
     * Constructs a new binding from a query solution.
     *
     * @param binding -
     */
    public BindingHashMapOverwrite(final QuerySolution binding) {
        var = null;
        node = null;
        if (binding == null) {
            parent = null;
        } else {
            final BindingHashMap p = new BindingHashMap();
            for (Iterator<String> it = binding.varNames(); it.hasNext();) {
                final String varName = it.next();
                if (binding.get(varName) != null) {
                    p.add(Var.alloc(varName), binding.get(varName).asNode());
                }
            }
            parent = p;
        }
//        LOG.trace("New binding #" + System.identityHashCode(this) + " copies " + binding);
    }
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:23,代码来源:BindingHashMapOverwrite.java

示例10: varsList

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
 * Lists the variables of this binding.
 *
 * @return The list of variables.
 */
public final List<Var> varsList() {
    List<Var> vars = new ArrayList<>();
    if (var != null) {
        vars.add(var);
    }
    if (parent != null) {
        for (Iterator<Var> it = parent.vars(); it.hasNext();) {
            Var v = it.next();
            if (!v.equals(var)) {
                vars.add(v);
            }
        }   
    }
    return vars;
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:21,代码来源:BindingHashMapOverwrite.java

示例11: outputValuesOneRow

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
private static void outputValuesOneRow(IndentedWriter out, List<Var> variables, Binding row, SerializationContext cxt) {
    // A value may be null for UNDEF
    for (Var var : variables) {
        out.print(" ");
        Node value = row.get(var);
        if (value == null) {
            out.print("UNDEF");
        } else {
            // Context for bnodes.
            // Bnodes don't occur in legal syntax but a rewritten query may
            // have them.  The output will not be legal SPARQL.
            // ARQ (SPARQL with extensions) does parse blankd nodes in VALUES. 
            SPARQLGenerateFmtUtils.printNode(out, value, cxt);
        }
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:17,代码来源:SPARQLGenerateQuerySerializer.java

示例12: asBinding

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/**
 * Turns a QuerySolution into a Binding. 
 * @param map  the input QuerySolution
 * @return a Binding or null if the input is null
 */
public static Binding asBinding(final QuerySolution map) {
	if(map != null) {
		BindingHashMap result = new BindingHashMap();
		Iterator<String> varNames = map.varNames();
		while(varNames.hasNext()) {
			String varName = varNames.next();
			RDFNode node = map.get(varName);
			if(node != null) {
				result.add(Var.alloc(varName), node.asNode());
			}
		}
		return result;
	}
	else {
		return null;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:23,代码来源:JenaUtil.java

示例13: exec

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public QueryIterator exec(Binding binding, PropFuncArg argSubject,
		Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {

	argSubject = Substitute.substitute(argSubject, binding);
	argObject = Substitute.substitute(argObject, binding);
	
	if(!argObject.getArg().isVariable()) {
		throw new ExprEvalException("Right hand side of tosh:targetContains must be a variable");
	}
	
	Node targetNode = argSubject.getArgList().get(0);
	Node shapesGraphNode = argSubject.getArgList().get(1);
	
	Model currentModel = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
	Dataset dataset = new DatasetWithDifferentDefaultModel(currentModel, DatasetImpl.wrap(execCxt.getDataset()));

	Model model = dataset.getNamedModel(shapesGraphNode.getURI());
	Resource target = (Resource) model.asRDFNode(targetNode);

	Set<Node> focusNodes = new HashSet<Node>();
	SHACLUtil.addNodesInTarget(target, dataset, focusNodes);
	return new QueryIterExtendByVar(binding, (Var) argObject.getArg(), focusNodes.iterator(), execCxt);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:25,代码来源:TargetContainsPFunction.java

示例14: moveToNextBinding

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
@Override
protected Binding moveToNextBinding() {
	// we need a binding that's ?s ?p ?o
	try {
		Triple triple = triples.next();
		BindingMap binding = BindingFactory.create();
		binding.add(Var.alloc("s"), triple.getSubject());
		binding.add(Var.alloc("p"), triple.getPredicate());
		binding.add(Var.alloc("o"), triple.getObject());
		return binding;
	} catch (RiotException e) {
		// bug in empty results for describe.  this is
		// a workaround. TODO
	}
	return BindingFactory.binding();
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:17,代码来源:MarkLogicQueryEngine.java

示例15: check

import org.apache.jena.sparql.core.Var; //导入依赖的package包/类
/** Check:
 * <ul>
 * <li>All variables in the head are mentioned in the body.
 * </ul>
 */
private void check() {
    if ( head == null )
        throw new RuleException("Null head");
    if ( head == null )
        return ;
    Set<Var> vars = new HashSet<>();
    if ( body != null ) {
        for(Rel br : body ) {
            accVars(vars, br);
        }
    }
    for ( Node n : head.getTuple() ) {
        if ( Var.isVar(n) ) {
            if ( ! vars.contains(n) )
                throw new RuleException("Variable '"+n+"' in head but not in body"); 
        }
    }
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:24,代码来源:Rule.java


注:本文中的org.apache.jena.sparql.core.Var类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。