Class Triple

java.lang.Object
org.apache.jena.graph.Triple
All Implemented Interfaces:
Serializable

public class Triple extends Object implements Serializable
Triples are the basis for RDF statements; they have a subject, predicate, and object field (all nodes) and express the notion that the relationship named by the predicate holds between the subject and the object.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A Field is a selector from Triples; it allows selectors to be passed around as if they were functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Triple
    A Triple that has Node.ANY in all fields.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Triple
    create(Node s, Node p, Node o)
    Create triple, Nulls are not permnitted.
    static Triple
    Create triple, Nulls are converted to Node.ANY.
    boolean
    Answer true if o is a Triple with the same subject, predicate, and object as this triple.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Deprecated, for removal: This API element is subject to removal in a future version.
    final Node
     
    final Node
     
    final Node
     
    int
    The hash-code of a triple is the hash-codes of its components munged together: see hashCode(S, P, O).
    static int
    hashCode(Node s, Node p, Node o)
    Return the munged hashCodes of the specified nodes, an exclusive-or of the slightly-shifted component hashcodes; this means (almost) all of the bits count, and the order matters, so (S P O) has a different hash from (O P S), etc.
    boolean
     
    boolean
    matches(Node s, Node p, Node o)
     
    boolean
    matches(Triple other)
    Does this triple, match the other triple, allowing for wildcards.
    boolean
    sameAs(Node s, Node p, Node o)
    Answer true iff this triple has subject s, predicate p, and object o.
    return a human-readable string "subject @predicate object" describing the triple
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ANY

      public static final Triple ANY
      A Triple that has Node.ANY in all fields.
  • Method Details

    • create

      public static Triple create(Node s, Node p, Node o)
      Create triple, Nulls are not permnitted.
    • createMatch

      public static Triple createMatch(Node s, Node p, Node o)
      Create triple, Nulls are converted to Node.ANY.
    • toString

      public String toString()
      return a human-readable string "subject @predicate object" describing the triple
      Overrides:
      toString in class Object
    • toString

      public String toString(PrefixMapping pm)
    • getSubject

      public final Node getSubject()
      Returns:
      the subject of the triple
    • getPredicate

      public final Node getPredicate()
      Returns:
      the predicate of the triple
    • getObject

      public final Node getObject()
      Returns:
      the object of the triple
    • getMatchSubject

      @Deprecated(forRemoval=true) public Node getMatchSubject()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return subject or null, not Node.ANY
    • getMatchPredicate

      @Deprecated(forRemoval=true) public Node getMatchPredicate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return predicate or null, not Node.ANY.
    • getMatchObject

      @Deprecated(forRemoval=true) public Node getMatchObject()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return object or null, not Node.ANY.
    • isConcrete

      public boolean isConcrete()
    • equals

      public boolean equals(Object o)
      Answer true if o is a Triple with the same subject, predicate, and object as this triple.
      Overrides:
      equals in class Object
    • sameAs

      public boolean sameAs(Node s, Node p, Node o)
      Answer true iff this triple has subject s, predicate p, and object o. The relationship is "same term". Use matches(Node, Node, Node) for wildcards.
    • matches

      public boolean matches(Triple other)
      Does this triple, match the other triple, allowing for wildcards. The wildcard node is Node.ANY and it matches any node, including a wildcard. Both this triple and the argument triple may contain wildcards, that is "matches" is symmetric: this.matches(that) == that.matches(this).
    • matches

      public boolean matches(Node s, Node p, Node o)
    • hashCode

      public int hashCode()
      The hash-code of a triple is the hash-codes of its components munged together: see hashCode(S, P, O).
      Overrides:
      hashCode in class Object
    • hashCode

      public static int hashCode(Node s, Node p, Node o)
      Return the munged hashCodes of the specified nodes, an exclusive-or of the slightly-shifted component hashcodes; this means (almost) all of the bits count, and the order matters, so (S P O) has a different hash from (O P S), etc.