org.apache.commons.rdf.api.Triple类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.apache.commons.rdf.api.Triple类的一些代码示例,展示了Triple类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Triple类的具体详情如下:
包路径:org.apache.commons.rdf.api.Triple
类名称:Triple

Triple介绍

[英]An RDF-1.1 Triple, as defined by RDF-1.1 Concepts and Abstract Syntax, a W3C Recommendation published on 25 February 2014.
[中]根据2014年2月25日发布的W3C建议RDF-1.1 Concepts and Abstract Syntax定义的{$0$}。

代码示例

代码示例来源: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: 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: 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.apache.commons/commons-rdf-api

assertEquals("\"The Secret Club\"",
    stream.filter(t -> !graph.contains((BlankNodeOrIRI) t.getObject(), knows, t.getSubject()))
        .map(knowsTriple -> {
          try (Stream<? extends Triple> memberOf = graph
              .stream((BlankNodeOrIRI) knowsTriple.getObject(), member, null)) {
            return memberOf
                .filter(memberTriple -> graph.contains(knowsTriple.getSubject(), member,
                    memberTriple.getObject()))
                .findFirst().get().getObject();
          try (Stream<? extends Triple> orgName = graph.stream((BlankNodeOrIRI) org, name,
              null)) {
            return orgName.findFirst().get().getObject().ntriplesString();

代码示例来源:origin: trellis-ldp/trellis

/**
   * Determine whether the object is an IRI.
   *
   * @return true if the object is an IRI; false otherwise
   */
  public boolean getObjectIsIRI() {
    return triple.getObject() instanceof 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: trellis-ldp/trellis

/**
 * Get the subject of the triple as a string.
 *
 * @return a string form of the subject
 */
public String getSubject() {
  if (triple.getSubject() instanceof IRI) {
    return ((IRI) triple.getSubject()).getIRIString();
  }
  return triple.getSubject().ntriplesString();
}

代码示例来源:origin: trellis-ldp/trellis

private static Predicate<Triple> inDomainRangeFilter(final String domain) {
  return triple -> propertiesWithInDomainRange.contains(triple.getPredicate()) &&
    !triple.getObject().ntriplesString().startsWith("<" + domain);
}

代码示例来源:origin: org.apache.commons/commons-rdf-api

@Test
public void asQuad() throws Exception {
  final Quad q = new DummyQuad();
  final Triple t = q.asTriple();
  assertEquals(t, t);
  assertNotEquals(t,  q);
  assertEquals(t, new DummyTriple());
  assertEquals(t, new DummyQuad().asTriple());
  // FIXME: This would not catch if asTriple() accidentally mixed up s/p/o
  // as they are here all the same
  assertEquals(new DummyIRI(1), t.getSubject());
  assertEquals(new DummyIRI(2), t.getPredicate());
  assertEquals(new DummyIRI(3), t.getObject());
  assertEquals(Objects.hash(q.getSubject(), q.getPredicate(), q.getObject()), t.hashCode());
}

代码示例来源:origin: commons-rdf/commons-rdf

(BlankNodeOrIRI) t.getObject(), knows,
    t.getSubject()))
.map(knowsTriple -> graph
            .getObject(), member, null)
        knowsTriple.getSubject(), member,
        memberTriple.getObject())).findFirst()
    .get().getObject())
    .findFirst().get().getObject().ntriplesString())
.findFirst().get());

代码示例来源:origin: org.trellisldp/trellis-rdfa

/**
   * Determine whether the object is an IRI.
   *
   * @return true if the object is an IRI; false otherwise
   */
  public boolean getObjectIsIRI() {
    return triple.getObject() instanceof IRI;
  }
}

代码示例来源: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.trellisldp/trellis-rdfa

/**
 * 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-rdfa

/**
 * Get the subject of the triple as a string.
 *
 * @return a string form of the subject
 */
public String getSubject() {
  if (triple.getSubject() instanceof IRI) {
    return ((IRI) triple.getSubject()).getIRIString();
  }
  return triple.getSubject().ntriplesString();
}

代码示例来源: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-rdfa

/**
 * Get the title.
 *
 * @return a title for the resource
 */
public String getTitle() {
  final Map<IRI, List<String>> titles = triples.stream()
    .filter(triple -> titleCandidates.contains(triple.getPredicate()))
    .filter(triple -> triple.getObject() instanceof Literal)
    .collect(groupingBy(Triple::getPredicate, mapping(triple ->
            ((Literal) triple.getObject()).getLexicalForm(), toList())));
  return titleCandidates.stream().filter(titles::containsKey)
    .map(titles::get).flatMap(List::stream).findFirst()
    .orElseGet(this::getSubject);
}

代码示例来源:origin: trellis-ldp/trellis

.collect(toList());
assertTrue(triples.stream().anyMatch(t -> t.getSubject().equals(identifier)), "subject not in triple stream!");
assertTrue(triples.stream().anyMatch(t -> t.getObject().equals(literal)), "Literal not in triple stream!");
assertTrue(triples.stream().anyMatch(t -> t.getSubject().ntriplesString()
      .startsWith("<" + TRELLIS_BNODE_PREFIX)), "Skolemized bnode not in triple stream!");

代码示例来源:origin: org.trellisldp/trellis-rdfa

/**
 * Get the object of the triple as a string.
 *
 * @return the string form of the object
 */
public String getObject() {
  if (triple.getObject() instanceof Literal) {
    return ((Literal) triple.getObject()).getLexicalForm();
  } else if (triple.getObject() instanceof IRI) {
    return ((IRI) triple.getObject()).getIRIString();
  }
  return triple.getObject().ntriplesString();
}

代码示例来源:origin: org.apache.commons/commons-rdf-api

@Test
public void getPredicate() throws Exception {
  assertEquals(2, ((DummyIRI) triple.getPredicate()).i);
}
@Test

相关文章