Package org.apache.jena.graph
Class Triple
- java.lang.Object
-
- org.apache.jena.graph.Triple
-
- All Implemented Interfaces:
java.io.Serializable
public class Triple extends java.lang.Object implements java.io.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Triple.Field
A Field is a selector from Triples; it allows selectors to be passed around as if they were functions, hooray.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Triple
create(Node s, Node p, Node o)
static Triple
createMatch(Node s, Node p, Node o)
boolean
equals(java.lang.Object o)
Answer true ifo
is a Triple with the same subject, predicate, and object as this triple.Node
getMatchObject()
Return object or null, not Node.ANYNode
getMatchPredicate()
Return predicate or null, not Node.ANYNode
getMatchSubject()
Return subject or null, not Node.ANYNode
getObject()
Node
getPredicate()
Node
getSubject()
int
hashCode()
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
isConcrete()
boolean
matches(Node s, Node p, Node o)
boolean
matches(Triple other)
Does this triple, used as a pattern match, the other triple (usually a ground triple)boolean
objectMatches(Node o)
boolean
predicateMatches(Node p)
boolean
sameAs(Node s, Node p, Node o)
Answer true iff this triple has subject s, predicate p, and object o.boolean
subjectMatches(Node s)
java.lang.String
toString()
return a human-readable string "subject @predicate object" describing the triplejava.lang.String
toString(PrefixMapping pm)
-
-
-
Field Detail
-
ANY
public static final Triple ANY
A Triple that is wildcarded in all fields.
-
-
Method Detail
-
toString
public java.lang.String toString()
return a human-readable string "subject @predicate object" describing the triple- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.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
public Node getMatchSubject()
Return subject or null, not Node.ANY
-
getMatchPredicate
public Node getMatchPredicate()
Return predicate or null, not Node.ANY
-
getMatchObject
public Node getMatchObject()
Return object or null, not Node.ANY
-
isConcrete
public boolean isConcrete()
-
equals
public boolean equals(java.lang.Object o)
Answer true ifo
is a Triple with the same subject, predicate, and object as this triple.- Overrides:
equals
in classjava.lang.Object
-
sameAs
public boolean sameAs(Node s, Node p, Node o)
Answer true iff this triple has subject s, predicate p, and object o.
-
matches
public boolean matches(Triple other)
Does this triple, used as a pattern match, the other triple (usually a ground triple)
-
subjectMatches
public boolean subjectMatches(Node s)
-
predicateMatches
public boolean predicateMatches(Node p)
-
objectMatches
public boolean objectMatches(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 classjava.lang.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.
-
-