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

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

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

Triple.getObject介绍

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

代码示例

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

/**
 * 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: 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-jsonld-java

@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: 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());
}

相关文章