本文整理匯總了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));
}
}
示例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);
}
示例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);
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}