本文整理汇总了Java中org.apache.marmotta.ldpath.model.selectors.PropertySelector类的典型用法代码示例。如果您正苦于以下问题:Java PropertySelector类的具体用法?Java PropertySelector怎么用?Java PropertySelector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertySelector类属于org.apache.marmotta.ldpath.model.selectors包,在下文中一共展示了PropertySelector类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.apache.marmotta.ldpath.model.selectors.PropertySelector; //导入依赖的package包/类
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
TestingSelector testingSelector = (TestingSelector) nodeSelector;
FunctionTest functionTest = (FunctionTest) testingSelector.getTest();
if(functionTest.getArgSelectors().get(0) instanceof PropertySelector) {
PropertySelector arg = (PropertySelector) functionTest.getArgSelectors().get(0);
PropertySelector delegate = (PropertySelector) testingSelector.getDelegate();
Var target = Var.alloc(VarIDGenerator.createID());
elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(delegate.getProperty().toString()), target));
Var selector = Var.alloc(VarIDGenerator.createID());
elementGroup.addTriplePattern(new Triple(target.asNode(), NodeFactory.createURI(arg.getProperty().toString()), selector.asNode()));
elementGroup.addElementFilter(new ElementFilter(new E_IsLiteral(new ExprVar(selector))));
return selector;
} else {
throw new IllegalStateException("Argument of function isLiteral has to be a PropertySelector");
}
}
示例2: testParsePath
import org.apache.marmotta.ldpath.model.selectors.PropertySelector; //导入依赖的package包/类
@Test
public void testParsePath() throws Exception {
String path1 = "rdfs:label";
NodeSelector<Value> s1 = parseSelector(path1, null);
Assert.assertThat(s1, CoreMatchers.instanceOf(PropertySelector.class));
Assert.assertEquals("<http://www.w3.org/2000/01/rdf-schema#label>",s1.getPathExpression(backend));
Map<String,String> namespaces2 = ImmutableMap.of(
"dct","http://purl.org/dc/terms/",
"dbp-ont","http://dbpedia.org/ontology/"
);
String path2 = "(*[rdf:type is dbp-ont:Person]) | (dct:subject/^dct:subject[rdf:type is dbp-ont:Person]) | (dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person])";
NodeSelector<Value> s2 = parseSelector(path2,namespaces2);
Assert.assertThat(s2, CoreMatchers.instanceOf(UnionSelector.class));
String path3 = "*[rdf:type is dbp-ont:Person] | dct:subject/^dct:subject[rdf:type is dbp-ont:Person] | dct:subject/^skos:broader/^dct:subject[rdf:type is dbp-ont:Person]";
NodeSelector<Value> s3 = parseSelector(path3,namespaces2);
Assert.assertThat(s3, CoreMatchers.instanceOf(UnionSelector.class));
String path4 = "(* | dct:subject/^dct:subject | dct:subject/^skos:broader/^dct:subject)[rdf:type is dbp-ont:Person]";
NodeSelector<Value> s4 = parseSelector(path4,namespaces2);
Assert.assertThat(s4, CoreMatchers.instanceOf(TestingSelector.class));
}
示例3: evaluate
import org.apache.marmotta.ldpath.model.selectors.PropertySelector; //导入依赖的package包/类
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
PropertySelector propertySelector = (PropertySelector) nodeSelector;
if (propertySelector instanceof WildcardSelector) {
throw new IllegalStateException(propertySelector.getClass() + " is not supported.");
}
Var id = Var.alloc(VarIDGenerator.createID());
elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(propertySelector.getProperty().toString()), id.asNode()));
return id;
}
示例4: IsATest
import org.apache.marmotta.ldpath.model.selectors.PropertySelector; //导入依赖的package包/类
public IsATest(Node rdfType, Node node) {
super(new PropertySelector<Node>(rdfType), node);
}