當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。