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


Java NodeValue.makeNode方法代码示例

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


在下文中一共展示了NodeValue.makeNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLang

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入方法依赖的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

示例2: testDisjunction

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入方法依赖的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

示例3: testSameTerm

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入方法依赖的package包/类
public void testSameTerm()
{
	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 sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint));
	
	Expression result = TransformExprToSQLApplyer.convert(sameTerm, intvalue);
	TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
	Expression expected = nm.valueMaker().valueExpression("1");
	
	assertEquals("sameTerm(?o, \"1\"^^xsd:int)", expected, result);
	
	sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDdecimal));
	
	result = TransformExprToSQLApplyer.convert(sameTerm, intvalue);
	
	assertEquals("sameTerm(?o, \"1\"^^xsd:decimal)", Expression.FALSE, result);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:ExprTransformTest2.java


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