本文整理了Java中org.apache.commons.rdf.api.Triple.getPredicate()
方法的一些代码示例,展示了Triple.getPredicate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Triple.getPredicate()
方法的具体详情如下:
包路径:org.apache.commons.rdf.api.Triple
类名称:Triple
方法名:getPredicate
[英]The predicate IRI of this triple.
[中]这个三元组的谓词IRI。
代码示例来源:origin: trellis-ldp/trellis
/**
* Get the predicate of the triple as a string.
*
* @return the string form of the predicate
*/
public String getPredicate() {
return triple.getPredicate().getIRIString();
}
代码示例来源:origin: org.trellisldp/trellis-constraint-rules
private static Predicate<Triple> inDomainRangeFilter(final String domain) {
return triple -> propertiesWithInDomainRange.contains(triple.getPredicate()) &&
!triple.getObject().ntriplesString().startsWith("<" + domain);
}
代码示例来源:origin: trellis-ldp/trellis
private static Map<IRI, RDFTerm> init(final IRI identifier, final File file) {
try (final Stream<Triple> triples = fetchContent(identifier, file).filter(q ->
q.getGraphName().filter(isEqual(Trellis.PreferServerManaged)).isPresent()).map(Quad::asTriple)) {
return triples.collect(toMap(t -> !t.getSubject().equals(identifier) && DC.modified.equals(t.getPredicate())
? Time.hasTime : t.getPredicate(), Triple::getObject));
}
}
代码示例来源:origin: trellis-ldp/trellis
private Predicate<IRI> isAgentInGroup(final IRI agent) {
return group -> resourceService.get(cleanIdentifier(group)).thenApply(res -> {
try (final Stream<RDFTerm> triples = res.stream(Trellis.PreferUserManaged)
.filter(t -> t.getSubject().equals(group) && t.getPredicate().equals(VCARD.hasMember))
.map(Triple::getObject)) {
return triples.anyMatch(agent::equals);
}
}).toCompletableFuture().join();
}
代码示例来源:origin: org.apache.commons/commons-rdf-jsonld-java
@Override
public void add(final Triple t) {
// Ensure it's added in the correct graph
super.add(graphName.orElse(null), t.getSubject(), t.getPredicate(), t.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-jsonld-java
@Override
public void remove(final Triple t) {
// Remove from ALL graphs, not just default graph
super.remove(null, t.getSubject(), t.getPredicate(), t.getObject());
}
代码示例来源:origin: org.trellisldp/trellis-api
/**
* Get a mapping function to turn a triple into a quad.
*
* @param graphName the graph name
* @return the mapping function
*/
public static Function<Triple, Quad> toQuad(final IRI graphName) {
return triple -> rdf.createQuad(graphName, triple.getSubject(), triple.getPredicate(), triple.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-jsonld-java
@Override
public void remove(final Triple t) {
// Only remove from the particular graph
remove(graphName, t.getSubject(), t.getPredicate(), t.getObject());
}
代码示例来源:origin: commons-rdf/commons-rdf
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Triple)) {
return false;
}
Triple other = (Triple) obj;
return getSubject().equals(other.getSubject())
&& getPredicate().equals(other.getPredicate())
&& getObject().equals(other.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-simple
private Triple internallyMap(final Triple triple) {
final BlankNodeOrIRI newSubject = (BlankNodeOrIRI) internallyMap(triple.getSubject());
final IRI newPredicate = (IRI) internallyMap(triple.getPredicate());
final RDFTerm newObject = internallyMap(triple.getObject());
// Check if any of the object references changed during the mapping, to
// avoid creating a new Triple object if possible
if (newSubject == triple.getSubject() && newPredicate == triple.getPredicate()
&& newObject == triple.getObject()) {
return triple;
}
return factory.createTriple(newSubject, newPredicate, newObject);
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
private static List<RDFTerm> tripleList(final Triple q) {
return Arrays.asList(
q.getSubject(),
q.getPredicate(),
q.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-simple
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof Triple)) {
return false;
}
final Triple other = (Triple) obj;
return getSubject().equals(other.getSubject()) && getPredicate().equals(other.getPredicate())
&& getObject().equals(other.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void getPredicate() throws Exception {
assertEquals(2, ((DummyIRI) triple.getPredicate()).i);
}
@Test
代码示例来源:origin: org.trellisldp/trellis-triplestore
@Override
public CompletionStage<Void> add(final IRI id, final Dataset dataset) {
return runAsync(() -> {
final IRI graphName = rdf.createIRI(id.getIRIString() + "?ext=audit");
try (final Dataset data = rdf.createDataset()) {
dataset.getGraph(PreferAudit).ifPresent(g ->
g.stream().forEach(t -> data.add(graphName, t.getSubject(), t.getPredicate(), t.getObject())));
executeWrite(rdfConnection, () -> rdfConnection.loadDataset(asJenaDataset(data)));
} catch (final Exception ex) {
throw new RuntimeTrellisException("Error storing audit dataset for " + id, ex);
}
});
}
代码示例来源:origin: trellis-ldp/trellis
/**
* Convert triples from a skolemized form to an externa form.
*
* @param svc the resourceService
* @param baseUrl the base URL
* @return a mapping function
*/
public static Function<Triple, Triple> unskolemizeTriples(final ResourceService svc, final String baseUrl) {
return triple -> rdf.createTriple((BlankNodeOrIRI) svc.toExternal(svc.unskolemize(triple.getSubject()),
baseUrl), triple.getPredicate(), svc.toExternal(svc.unskolemize(triple.getObject()), baseUrl));
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testHashCode() {
final int expected = Objects.hash(triple.getSubject(), triple.getPredicate(), triple.getObject());
assertEquals(expected, triple.hashCode());
}
}
代码示例来源:origin: org.trellisldp/trellis-rdfa
private LabelledTriple labelTriple(final Triple triple) {
final String pred = triple.getPredicate().getIRIString();
if (triple.getObject() instanceof IRI) {
return new LabelledTriple(triple, getLabel(pred), getLabel(((IRI) triple.getObject()).getIRIString()));
} else if (triple.getObject() instanceof Literal) {
return new LabelledTriple(triple, getLabel(pred), ((Literal) triple.getObject()).getLexicalForm());
}
return new LabelledTriple(triple, getLabel(pred), triple.getObject().ntriplesString());
}
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeIRI() {
final BlankNode subject = factory.createBlankNode("b1");
final IRI predicate = factory.createIRI("http://example.com/pred");
final IRI object = factory.createIRI("http://example.com/obj");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeBnode() {
final BlankNode subject = factory.createBlankNode("b1");
final IRI predicate = factory.createIRI("http://example.com/pred");
final BlankNode object = factory.createBlankNode("b2");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void testCreateTripleBnodeTriple() {
final BlankNode subject = factory.createBlankNode();
final IRI predicate = factory.createIRI("http://example.com/pred");
final Literal object = factory.createLiteral("Example", "en");
final Triple triple = factory.createTriple(subject, predicate, object);
// bnode equivalence should be OK as we used the same
// factory and have not yet inserted Triple into a Graph
assertEquals(subject, triple.getSubject());
assertEquals(predicate, triple.getPredicate());
assertEquals(object, triple.getObject());
}
内容来源于网络,如有侵权,请联系作者删除!