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


Java ExprVar类代码示例

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


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

示例1: visit

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public void visit(ExprVar var)
{
	logger.debug("visit ExprVar " + var);
	
	if (!convertable) {
		expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
		return;                            // fails in the middle of a multi-arg operator conversion
	}
	
	String varName = var.getVarName();
	
	// if expression contains a blank node, no conversion to sql can be done
	if (Var.isBlankNodeVarName(varName)) {
		conversionFailed("blank nodes not supported", var);
		return;
	}
	
	List<Expression> expressions = toExpression(var);
	if (expressions.size() == 1) {
		expression.push(expressions.get(0));
	} else {
		// no single sql-column for sparql-var does exist break up conversion
		// (the case for Pattern ValueMakers)
		conversionFailed("multi column pattern valuemakers not supported", var);
	}
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:27,代码来源:TransformExprToSQLApplyer.java

示例2: testLang

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public void testLang()
{
	List<Triple> pattern = new ArrayList<Triple>();
	pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
	NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation label_fr_be  = search("table1", "label_fr_be", rels);
	NodeRelation label_en     = search("table1", "label_en", rels);
	NodeRelation label_noLang = search("table1", "label", rels);
	
	Expr filterFR    = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr"));
	Expr filterEN_TAG_EN = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeNode("en", "en", (String) null));
	Expr filterFR_BE = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr-BE"));
	Expr filter      = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString(""));
	
	assertEquals("LANG(label_fr_be) = \"fr\" should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_fr_be));
	assertEquals("LANG(label_en) = \"fr\" should be FALSE",      Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_en));
	assertEquals("LANG(label_fr_be) = \"fr_be\" should be TRUE", Expression.TRUE,  TransformExprToSQLApplyer.convert(filterFR_BE, label_fr_be));
	assertEquals("LANG(label_en) = \"en\"@en should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterEN_TAG_EN, label_en));
	assertEquals("LANG(label_noLang) = \"\" should be TRUE",     Expression.TRUE,  TransformExprToSQLApplyer.convert(filter, label_noLang));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:22,代码来源:ExprTransformTest2.java

示例3: testDataType

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public void testDataType()
{
	List<Triple> pattern = new ArrayList<Triple>();
	pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
	NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation intvalue = search("table2", "intvalue", rels);
	NodeRelation value = search("table2", "value", rels);
	
	pattern.clear();
	pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
	rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation langliteral = search("table1", "label_en", rels);
	
	Expr filterint    = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDint.getURI())));
	Expr filterstring = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDstring.getURI())));
	
	assertEquals("DATATYPE(intliteral) = xsd:int should be TRUE",       Expression.TRUE, TransformExprToSQLApplyer.convert(filterint, intvalue));
	assertEquals("DATATYPE(simpleliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, value));
	assertEquals("DATATYPE(langliteral) = xsd:string should be TRUE",   Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, langliteral));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:ExprTransformTest2.java

示例4: testDisjunction

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public void testDisjunction()
{
	List<Triple> pattern = new ArrayList<Triple>();
	pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
	NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation intvalue = search("table2", "intvalue", rels);

	Expr disjunction = new E_LogicalOr(new E_Equals(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint)), new E_Equals(new ExprVar("o"), NodeValue.makeNode("2", XSDDatatype.XSDint)));
	
	Expression result = TransformExprToSQLApplyer.convert(disjunction, intvalue);
	TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
	Expression e1 = nm.valueMaker().valueExpression("1");
	Expression e2 = nm.valueMaker().valueExpression("2");
	Expression expected = e1.or(e2);
	
	assertEquals("?o = \"1\"^^xsd:int || ?o = \"2\"^^xsd:int", expected, result);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:19,代码来源:ExprTransformTest2.java

示例5: evaluate

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    FunctionTest functionTest = (FunctionTest) testingSelector.getTest();

    if(functionTest.getArgSelectors().get(0) instanceof PropertySelector) {
        PropertySelector arg = (PropertySelector) functionTest.getArgSelectors().get(0);
        PropertySelector delegate = (PropertySelector) testingSelector.getDelegate();

        Var target = Var.alloc(VarIDGenerator.createID());
        elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(delegate.getProperty().toString()), target));

        Var selector = Var.alloc(VarIDGenerator.createID());
        elementGroup.addTriplePattern(new Triple(target.asNode(), NodeFactory.createURI(arg.getProperty().toString()), selector.asNode()));

        elementGroup.addElementFilter(new ElementFilter(new E_IsLiteral(new ExprVar(selector))));

        return selector;
    } else {
        throw new IllegalStateException("Argument of function isLiteral has to be a PropertySelector");
    }
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:23,代码来源:IsLiteralTestEvaluator.java

示例6: parseTemplate

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public static E_StrConcatPermissive parseTemplate(String str) {
    ExprList args = new ExprList();

    while (!str.isEmpty()) {
        if (str.contains("{") && str.contains("}")) {
            int openIdx = str.indexOf('{');
            int closeIdx = str.indexOf('}');
            int strLen = str.length();

            if (openIdx > 0) {
                args.add(NodeValue.makeString(str.substring(0, openIdx)));
            }

            String varName = str.substring(openIdx+1, closeIdx);
            args.add(new ExprVar(Var.alloc(varName)));

            str = str.substring(closeIdx+1, strLen);

        } else {
            args.add(NodeValue.makeString(str));
            str = "";
        }
    }

    return new E_StrConcatPermissive(args);
}
 
开发者ID:AKSW,项目名称:sml-converters,代码行数:27,代码来源:RRUtils.java

示例7: VarOrFunction

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
final public Expr VarOrFunction() throws ParseException {
                       Var v ; ExprList a = null ;
  v = Var();
  Expr ev = new ExprVar(v) ;
  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  case LPAREN:
  case NIL:
    a = ExpressionList();
    break;
  default:
    jj_la1[164] = jj_gen;
    ;
  }
  if ( a == null ) {if (true) return ev ;}
  {if (true) return new E_FunctionDynamic(ev, a) ;}
  throw new Error("Missing return statement in function");
}
 
开发者ID:KMax,项目名称:cqels,代码行数:18,代码来源:CQELSParser.java

示例8: evaluate

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    IsATest isATest = (IsATest) nodeTest;
    Var tmpVar = Var.alloc(Var.alloc(VarIDGenerator.createID()));
    elementGroup.addTriplePattern(new Triple(var.asNode(), RDF.type.asNode(), tmpVar.asNode()));
    return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(isATest.getPathExpression(new SesameValueBackend()).replace("<", "").replace(">", "").replaceFirst("is-a ", ""))));
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:8,代码来源:IsATestEvaluator.java

示例9: evaluate

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    PathEqualityTest pathEqualityTest = (PathEqualityTest) nodeTest;
    Var tmpVar =  LDPathEvaluator.evaluate(pathEqualityTest.getPath(), elementGroup, var, evaluatorConfiguration);
    if(pathEqualityTest.getNode() instanceof org.openrdf.model.impl.LiteralImpl) {
        return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createLiteral(((LiteralImpl) pathEqualityTest.getNode()).getLabel().toString())));
    } else {
        return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(pathEqualityTest.getNode().toString())));
    }
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:11,代码来源:PathEqualityTestEvaluator.java

示例10: getViewCandidates

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
public Set<ViewQuad<ViewDefinition>> getViewCandidates(Triple triple) {
	Var g = Var.alloc("g");
	Var s = Var.alloc("s");
	Var p = Var.alloc("p");
	Var o = Var.alloc("o");

	Node gv = Quad.defaultGraphNodeGenerated;
	Node sv = triple.getSubject();
	Node pv = triple.getPredicate();
	Node ov = triple.getObject();
	
	Quad tmpQuad = new Quad(g, s, p, o);
	
	RestrictionManagerImpl r = new RestrictionManagerImpl();
	
	Set<Clause> clauses = new HashSet<Clause>();
	clauses.add(new Clause(new E_Equals(new ExprVar(g), NodeValue.makeNode(gv))));
	clauses.add(new Clause(new E_Equals(new ExprVar(s), NodeValue.makeNode(sv))));
	clauses.add(new Clause(new E_Equals(new ExprVar(p), NodeValue.makeNode(pv))));
	clauses.add(new Clause(new E_Equals(new ExprVar(o), NodeValue.makeNode(ov))));

	NestedNormalForm nnf = new NestedNormalForm(clauses);
	
	r.stateCnf(nnf);
	
	Set<ViewQuad<ViewDefinition>> result = candidateSelector.findCandidates(tmpQuad, r);
	
	return result;
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:30,代码来源:Pinpointer.java

示例11: transform

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
public Op transform(OpFilter opFilter, Op subOp) {

	ExprList substitutedExprList = new ExprList();
	
	for (Expr expr: opFilter.getExprs().getList()){
		Map<String, Expr> substitutions = new HashMap<String, Expr>();
		//for each expression see if it contains variables that are not mentioned within this clause
		for (Var var: expr.getVarsMentioned()){
			QueryVar mentionedQueryVar=this.mentionedVars.get(var);
			if (mentionedQueryVar==null) {
				//No mentioned variables so filter not relevant
				return subOp;
			}else
			{
				//Mentioned so add the new name to the substitutions set.
				Var substitutedVar = Var.alloc(mentionedQueryVar.getLinkedName(this.queryClause.getDataset()));
				substitutions.put(var.getName(), new ExprVar(substitutedVar));
			}
		}
		//Only get here if all vars mentioned in expression are within clause
	
		ExprTransformSubstitute exprTransformSubstitute = new ExprTransformSubstitute(	substitutions );
		Expr substitutedExpression = (Expr) ExprTransformer.transform(exprTransformSubstitute, expr);
		substitutedExprList.add(substitutedExpression);
	}
	return OpFilter.filter(substitutedExprList, subOp);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:29,代码来源:Substituter.java

示例12: createFilter

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
private ElementFilter createFilter(SparqlNodes label, SparqlNodes scheme) {
  return use(new SparqlUriExpression(new ExprVar(QUERIED_CONCEPT)).create(concept))//
      .and(
          createMultipleOptionsExpression(new SparqlLanguageExpression(label), getLanguages()),
          !getLanguages().isEmpty())
      .and(
          createMultipleOptionsExpression(new SparqlUriExpression(scheme), getSchemas()),
          !getSchemas().isEmpty())
      .toElementFilter();
}
 
开发者ID:eENVplus,项目名称:tf-exploitation-server,代码行数:11,代码来源:SynonymsCrossWalkingQueryBuilder.java

示例13: visit

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
public void visit(ExprVar nv) {
	log(nv);
	this.shadowed=nv;
	if(LOGGER.isDebugEnabled()) {
		LOGGER.debug(String.format("Shadowing detected: %s shadows %s",var,nv));
	}
}
 
开发者ID:ldp4j,项目名称:ldp4j,代码行数:9,代码来源:QueryTest.java

示例14: visit

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
@Override
   public void visit(ExprVar nv) {
nv.visit(visitor);
   }
 
开发者ID:aschaetzle,项目名称:S2X,代码行数:5,代码来源:ExprWalker.java

示例15: subst

import com.hp.hpl.jena.sparql.expr.ExprVar; //导入依赖的package包/类
private static Op subst(Op subOp , ExprVar var1, ExprVar var2) {
    // Replace var2 with var1
    Op op = Substitute.substitute(subOp, var2.asVar(), var1.asVar());
    // Insert LET(var2:=var1)
    return OpAssign.assign(op, var2.asVar(), var1);
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:7,代码来源:TransformFilterVarEquality.java


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