org.apache.commons.rdf.api.Triple.getSubject()方法的使用及代码示例

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

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

Triple.getSubject介绍

[英]The subject of this triple, which may be either a BlankNode or an IRI, which are represented in Commons RDF by the interface BlankNodeOrIRI.
[中]这个三元组的主题可以是BlankNode或IRI,它们在Commons RDF中由接口BlankNodeOri表示。

代码示例

代码示例来源: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: 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: 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) {
  // Only remove from the particular graph
  remove(graphName, 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

/**
 * Adapt a Commons RDF {@link Triple} as a JsonLd
 * {@link com.github.jsonldjava.core.RDFDataset.Quad}.
 *
 * @param triple
 *            Commons RDF {@link Triple} to adapt
 * @return Adapted JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}
 */
public RDFDataset.Quad asJsonLdQuad(final Triple triple) {
  return createJsonLdQuad(null, triple.getSubject(), triple.getPredicate(), triple.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-simple

@Override
public boolean contains(final Triple triple) {
  return dataset.contains(unionOrNamedGraph(), triple.getSubject(), triple.getPredicate(), triple.getObject());
}

代码示例来源: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 getSubject() throws Exception {
  assertEquals(1, ((DummyIRI) triple.getSubject()).i);
}
@Test

代码示例来源: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.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());
}

相关文章

微信公众号

最新文章

更多