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


Java Node类代码示例

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


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

示例1: buildBGP

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
private void buildBGP(OpBGP op) {
final List<Triple> triples = op.getPattern().getList();
for (final Triple triple : triples) {
    final Node subjectNode = triple.getSubject();
    final Node predicateNode = triple.getPredicate();
    final Node objectNode = triple.getObject();

    final String subject = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(subjectNode, prefixes));
    final String object = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(objectNode, prefixes));
    final String predicate = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(predicateNode, prefixes));

    if (bgp == null) {
	bgp = new ArrayList<TriplePattern>();
    }
    bgp.add(new TriplePattern(subject, predicate, object));
}
   }
 
开发者ID:aschaetzle,项目名称:S2X,代码行数:21,代码来源:SparkBGP.java

示例2: getValue

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
@Override
   public String getValue(SolutionMapping solution) {
String left = "";
String right = "";
if (expr1 instanceof ExprVar) {
    left = solution.getValueToField(((ExprVar) expr1).getVar());
} else {
    left = ((IValueType) expr1).getValue(solution);
}

if (expr2 instanceof ExprVar) {
    right = solution.getValueToField(((ExprVar) expr2).getVar());
} else {
    right = ((IValueType) expr2).getValue(solution);
}

Node nodeLeft = NodeFactoryExtra.parseNode(left);
Node nodeRight = NodeFactoryExtra.parseNode(right);
Integer leftInt = (Integer) nodeLeft.getLiteral().getValue();
Integer rightInt = (Integer) nodeRight.getLiteral().getValue();

int res = leftInt + rightInt;

return String.format(
	"\"%s\"^^<http://www.w3.org/2001/XMLSchema#integer>", res);
   }
 
开发者ID:aschaetzle,项目名称:S2X,代码行数:27,代码来源:Add.java

示例3: getValue

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
@Override
   public String getValue(SolutionMapping solution) {
String left = "";
String right = "";
if (expr1 instanceof ExprVar) {
    left = solution.getValueToField(((ExprVar) expr1).getVar());
} else {
    left = ((IValueType) expr1).getValue(solution);
}

if (expr2 instanceof ExprVar) {
    right = solution.getValueToField(((ExprVar) expr2).getVar());
} else {
    right = ((IValueType) expr2).getValue(solution);
}

Node nodeLeft = NodeFactoryExtra.parseNode(left);
Node nodeRight = NodeFactoryExtra.parseNode(right);
Integer leftInt = (Integer) nodeLeft.getLiteral().getValue();
Integer rightInt = (Integer) nodeRight.getLiteral().getValue();

int res = leftInt - rightInt;

return String.format(
	"\"%s\"^^<http://www.w3.org/2001/XMLSchema#integer>", res);
   }
 
开发者ID:aschaetzle,项目名称:S2X,代码行数:27,代码来源:Subtract.java

示例4: visit

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
/**
 * Visitor for the property path
 * @author Simon Skilevic
 */
@Override
public void visit(OpPath opPath) {
	// Path subject
	Node subject = opPath.getTriplePath().getSubject();
	// Path object
	Node object = opPath.getTriplePath().getObject();
	// Property path 
	Path tPath = opPath.getTriplePath().getPath();
	
	String stringPath = tPath.toString();
	ArrayList<String> pathsStr = TransformerHelper.findAllPossiblePathes(stringPath);
	int id=0;
	for (String path:pathsStr){
		BasicPattern pt = TransformerHelper.transformPathToBasicPattern(subject, path, object);
		OpBGP opBGP = new OpBGP(pt);
    	stack.push(new SqlBGP(opBGP, prefixes));
		id++;
		if (id>1) {
			 SqlOp rightOp = stack.pop();
		     SqlOp leftOp = stack.pop();
		     stack.push(new SQLUnion(null, leftOp, rightOp, prefixes));
		}
	}
	
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:30,代码来源:AlgebraTransformer.java

示例5: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		result.put(subject.getName(),
				new String[] { Tags.SUBJECT_COLUMN_NAME });
	if (predicate.isVariable()) {
		result.put(predicate.getName(),
				new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		result.put(object.getName(),
				new String[] { Tags.OBJECT_COLUMN_NAME });
	}
	return result;
}
 
开发者ID:aschaetzle,项目名称:S2RDF,代码行数:19,代码来源:TripleGroup.java

示例6: getSchemaOfTriple

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
protected ArrayList<String> getSchemaOfTriple(Triple t) {
	ArrayList<String> schema = new ArrayList<String>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		schema.add(subject.getName());
	else
		schema.add(Tags.NO_VAR);
	if (predicate.isVariable())
		schema.add(predicate.getName());
	else
		schema.add(Tags.NO_VAR);
	if (object.isVariable())
		schema.add(object.getName());
	else
		schema.add(Tags.NO_VAR);
	return schema;
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:20,代码来源:PigBGP.java

示例7: PrefixforExtVP

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
/**
 * Use defined prefixes for making predicates compatible with ExtVP table naming.
 * 
 * @param Predicate - Predicate to be renamed.
 * @return
 */
private String PrefixforExtVP(Node Predicate) {
	String URIPredicate = Predicate.toString();
	int index = URIPredicate.lastIndexOf('#');
	if (index == -1)
		index = URIPredicate.lastIndexOf('/');
	String URI = URIPredicate.substring(0, index + 1);
	String Pred = URIPredicate.substring(index + 1, URIPredicate.length());
	String Prefix = prefixes.getNsURIPrefix(URI);
	if (Prefix == null) {
		if (URI.contains("http"))
			return "_" + Pred + "_".replaceAll("[<>/.`~,\\s\\-:\\?]", "_");
		else {
			String RenamedURI = URI.replaceAll("[<>/.`~,\\s\\-:\\?]", "_");
			return RenamedURI + Pred;
		}
	} else
		return Prefix + "_" + Pred;
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:25,代码来源:ImpalaBgpExtVPMultiTable.java

示例8: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable()) {
		result.put(subject.getName(), new String[] { Tags.SUBJECT_COLUMN_NAME });
	}
	if (predicate.isVariable()) {
		selectFromTripleStore = true;
		result.put(predicate.getName(), new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		if (selectFromTripleStore) {
			result.put(object.getName(), new String[] { Tags.OBJECT_COLUMN_NAME });
		} else {
			String objectString = object.getName();
			String predicateString = getPropertyFromURI(FmtUtils
					.stringForNode(predicate, prefixMapping), false);
			result.put(objectString, new String[] { SpecialCharFilter.filter(predicateString) });
		}
	}
	return result;
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:25,代码来源:SparkComplexTripleGroup.java

示例9: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		result.put(subject.getName(),
				new String[] { Tags.SUBJECT_COLUMN_NAME });
	if (predicate.isVariable()) {
		selectFromTripleStore = true;
		result.put(predicate.getName(),
				new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		if (selectFromTripleStore) {
			result.put(object.getName(),
					new String[] { Tags.OBJECT_COLUMN_NAME });
		} else {
			result.put(object.getName(), new String[] { SpecialCharFilter
					.filter(FmtUtils
							.stringForNode(predicate, prefixMapping)) });
		}
	}
	return result;
}
 
开发者ID:aschaetzle,项目名称:Sempala,代码行数:26,代码来源:TripleGroup.java

示例10: verify

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
protected QueryIterator verify(Binding binding, Graph queryGraph, Node matchSubject, Node predicate,
		Node matchObject, ExecutionContext execCxt) {
	Geometry s=getGeometry(matchSubject, execCxt.getActiveGraph());
	Geometry o=getGeometry(matchObject, execCxt.getActiveGraph());
	try {
		if(evaluateSpatialRelation(s,o)){
			return IterLib.result(binding, execCxt);
		}
		else{
			return IterLib.noResults(execCxt);
		}
	} catch (GeometryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}return IterLib.noResults(execCxt);
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:17,代码来源:FunctionBaseSpatialRelation.java

示例11: verifyValue

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
@Override
protected QueryIterator verifyValue(Binding binding, Graph graph, Node product, Geometry geometry, Node object,
		ExecutionContext execCxt) {
	String obj;
	try{
	obj=(String)object.getLiteralValue();
	}catch (Exception e){
		return IterLib.noResults(execCxt);
	}
	String b=computeValue(geometry);
	if(b==null){
		return IterLib.noResults(execCxt);
	}
	if(b.equals(obj)){
		return IterLib.result(binding, execCxt);
	}
	return IterLib.noResults(execCxt);
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:19,代码来源:FunctionBaseProductEwktValue.java

示例12: getRelatedNodes

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
protected List<Node> getRelatedNodes(Node node, ExecutionContext execCxt) {
	Geometry geometry=getGeometry(node, execCxt.getActiveGraph());
	List<Node> nodes=new ArrayList<Node>();
	for (Node n:hashmap.keySet()){
		try {
			if(evaluateSpatialRelation(geometry, getGeometry(n,execCxt.getActiveGraph()))){
				nodes.add(n);
			}
		} catch (GeometryException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	nodes.remove(node);
	return nodes;   
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:17,代码来源:FunctionBaseSpatialRelation.java

示例13: toString

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
/**
 * Pretty-prints an RDF node and shortens URIs into QNames according to a
 * {@link PrefixMapping}.
 * @param n An RDF node
 * @return An N-Triples style textual representation with URIs shortened to QNames
 */
public static String toString(Node n, PrefixMapping prefixes) {
	if (n.isURI()) {
		return qNameOrURI(n.getURI(), prefixes);
	}
	if (n.isBlank()) {
		return "_:" + n.getBlankNodeLabel();
	}
	if (n.isVariable()) {
		return "?" + n.getName();
	}
	if (Node.ANY.equals(n)) {
		return "?ANY";
	}
	// Literal
	String s = "\"" + n.getLiteralLexicalForm() + "\"";
	if (!"".equals(n.getLiteralLanguage())) {
		s += "@" + n.getLiteralLanguage();
	}
	if (n.getLiteralDatatype() != null) {
		s += "^^" + qNameOrURI(n.getLiteralDatatypeURI(), prefixes);
	}
	return s;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:30,代码来源:PrettyPrinter.java

示例14: convertIsIRI

import com.hp.hpl.jena.graph.Node; //导入依赖的package包/类
private void convertIsIRI(E_IsIRI expr)
{
	logger.debug("convertIsIRI " + expr.toString());
	
	expr.getArg().visit(this);
	
	Expression arg = expression.pop();
	
	if (arg instanceof AttributeExprEx) {
		AttributeExprEx variable = (AttributeExprEx) arg;
		NodeMaker nm = variable.getNodeMaker();
		DetermineNodeType filter = new DetermineNodeType();
		nm.describeSelf(filter);
		expression.push(filter.isLimittedToURIs() ? Expression.TRUE : Expression.FALSE);
	} else if (arg instanceof ConstantEx) {
		ConstantEx constant = (ConstantEx) arg;
		Node node = constant.getNode();
		expression.push(node.isURI() ? Expression.TRUE : Expression.FALSE);
	} else {
		conversionFailed(expr);
	}
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:TransformExprToSQLApplyer.java

示例15: testDisjunction

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


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