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


Java NodeValue类代码示例

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


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

示例1: visit

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
public void visit(NodeValue value)
{
	logger.debug("visit NodeValue " + value);
	
	if (!convertable) {
		expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
		return;                            // fails in the middle of a multi-arg operator conversion
	}
	
	if (value.isDecimal() || value.isDouble() || value.isFloat() || value.isInteger() || value.isNumber()) {
		expression.push(new ConstantEx(value.asString(), value.asNode()));
	} else if (value.isDateTime()) {
		// Convert xsd:dateTime: CCYY-MM-DDThh:mm:ss
		// to SQL-92 TIMESTAMP: CCYY-MM-DD hh:mm:ss[.fraction]
		// TODO support time zones (WITH TIME ZONE columns)
		expression.push(new ConstantEx(value.asString().replace("T", " "), value.asNode()));
	} else {
		expression.push(new ConstantEx(value.asString(), value.asNode()));
	}
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:21,代码来源:TransformExprToSQLApplyer.java

示例2: convertLangMatches

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
private void convertLangMatches(E_LangMatches expr)
{
	logger.debug("convertLangMatches " + expr.toString());
	
	expr.getArg1().visit(this);
	expr.getArg2().visit(this);
	Expression e2 = expression.pop();
	Expression e1 = expression.pop();
	
	if (e1 instanceof ConstantEx && e2 instanceof ConstantEx) {
		ConstantEx lang1 = (ConstantEx) e1;
		ConstantEx lang2 = (ConstantEx) e2;
		NodeValue nv1 = NodeValue.makeString(lang1.getNode().getLiteral().getLexicalForm());
		NodeValue nv2 = NodeValue.makeString(lang2.getNode().getLiteral().getLexicalForm());
		NodeValue match = NodeFunctions.langMatches(nv1, nv2);
		expression.push(match.equals(NodeValue.TRUE) ? Expression.TRUE : Expression.FALSE);
	} else {
		expression.push(Expression.FALSE);
	}
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:21,代码来源:TransformExprToSQLApplyer.java

示例3: 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

示例4: 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

示例5: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
	try {
		Geometry g1 = GFUtils.read(v1);
		Geometry g2 = GFUtils.read(v2);
		int result=Topology.intersects3D(g1, g2);
    if(result==2||result==3||result==4||result==5){
    	return NodeValue.booleanReturn(true);
    }else{
    	return NodeValue.booleanReturn(false);
    }
	}  catch (GeometryException e) {
		e.printStackTrace();
		return NodeValue.booleanReturn(false);
	}  
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:17,代码来源:touches3D.java

示例6: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v) {
	EwktReader er=new EwktReader(v.getString());
		Geometry g;
		try {
			g = er.readGeometry();

		double volume = Volume.volume(g);
		return (NodeValue.makeDouble(volume));
	} catch (GeometryException | WktParseException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return (NodeValue.nvZERO);
	}
	
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:17,代码来源:volume.java

示例7: parseTemplate

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

示例8: visit

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public void visit(NodeValue nv) {
	try {
		stack.push(""+Integer.parseInt(FmtUtils.stringForNode(nv.asNode())));
	} catch (NumberFormatException e) {
		String value = FmtUtils.stringForNode(nv.asNode(), prefixes);
		if(value.contains("\"")){
			value.replace("\"", "");
		}
		stack.push("'"+value+"'");
	}
	
    
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:15,代码来源:ExprTranslator.java

示例9: visit

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public void visit(NodeValue nv) {
	try {
		stack.push(""+Integer.parseInt(FmtUtils.stringForNode(nv.asNode())));
	} catch (NumberFormatException e) {
		String value = FmtUtils.stringForNode(nv.asNode(), prefixes);
		if(value.contains("\"")){
			value.replace("\"", "");
		}
		stack.push("'"+value+"'");
	}


}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:15,代码来源:ExprTranslator.java

示例10: convertStr

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
private void convertStr(E_Str expr)
{
	logger.debug("convertStr " + expr.toString());
	
	expr.getArg().visit(this);
	
	Expression arg = expression.pop();
	
	if (arg instanceof AttributeExprEx) {
		// make a new AttributeExprEx with changed NodeMaker, which returns plain literal
		// TODO this seems to work, but needs more testing.
		AttributeExprEx attribute = (AttributeExprEx) arg;
		TypedNodeMaker nodeMaker = (TypedNodeMaker) attribute.getNodeMaker();
		TypedNodeMaker newNodeMaker = new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, nodeMaker.valueMaker(), nodeMaker.isUnique());
		logger.debug("changing nodemaker " + nodeMaker + " to " + newNodeMaker);
		expression.push(new AttributeExprEx((Attribute) attribute.attributes().iterator().next(), newNodeMaker));
	} else if (arg instanceof ConstantEx) {
		ConstantEx constant = (ConstantEx) arg;
		Node node = constant.getNode();
		String lexicalForm = node.getLiteral().getLexicalForm();
		node = Node.createLiteral(lexicalForm);
		ConstantEx constantEx = new ConstantEx(NodeValue.makeNode(node).asString(), node);
		logger.debug("pushing " + constantEx);
		expression.push(constantEx);
	} else {
		conversionFailed(expr);
	}
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:29,代码来源:TransformExprToSQLApplyer.java

示例11: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v) {
	Geometry g=GFUtils.read(v);
	Vector3d normal;
	try {
		normal = Normal.normal(g);
		Point3d p=new Point3d(normal.x,normal.y,normal.z);
		return GFUtils.write(p);
	} catch (GeometryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return NodeValue.nvEmptyString;
	}
	
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:16,代码来源:normal.java

示例12: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
	Geometry g=GFUtils.read(v1);
	double deep=v2.getDouble();
	try {
		Geometry geometry=Extrude.extrude(g, deep);
		return GFUtils.write(geometry);
	} catch (GeometryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return NodeValue.nvEmptyString;
	}
	
     
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:16,代码来源:extrude.java

示例13: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v) {
	// TODO Auto-generated method stub
	try {
		return NodeValue.makeDouble(Area.area(new EwktReader(v.getString()).readGeometry()));
	} catch (GeometryException | WktParseException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return NodeValue.makeDouble(0);
	}
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:12,代码来源:area.java

示例14: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
	try {
		Geometry g1 = GFUtils.read(v1);
		Geometry g2 = GFUtils.read(v2);
    if(Topology.intersects3D(g1, g2)==1){
    	return NodeValue.booleanReturn(true);
    }else{
    	return NodeValue.booleanReturn(false);
    }
	}  catch (GeometryException e) {
		e.printStackTrace();
		return NodeValue.booleanReturn(false);
	}  
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:16,代码来源:intersects3D.java

示例15: exec

import com.hp.hpl.jena.sparql.expr.NodeValue; //导入依赖的package包/类
@Override
public NodeValue exec(NodeValue v) {

		Geometry g=GFUtils.read(v);
	    try {
			Geometry projection=Projection.projectToXY(g);
			return GFUtils.write(projection);
		} catch (GeometryException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return NodeValue.nvEmptyString;
		}
	    
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:15,代码来源:projectionXY.java


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