Package org.apache.jena.graph
Class Node
- java.lang.Object
-
- org.apache.jena.graph.Node
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Node_Concrete
,Node_Ext
,Node_Fluid
,Node_Graph
,Node_Triple
public abstract class Node extends java.lang.Object implements java.io.Serializable
A Node has five subtypes: Node_Blank, Node_Anon, Node_URI, Node_Variable, and Node_ANY. Nodes are only constructed by the node factory methods, and they will attempt to re-use existing nodes with the same label if they are recent enough.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Node.NotLiteral
Exception thrown if a literal-access operation is attempted on a non-literal node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
equals(java.lang.Object o)
Nodes only equal other Nodes that have equal labels.BlankNodeId
getBlankNodeId()
get the blank node id if the node is blank, otherwise die horriblyjava.lang.String
getBlankNodeLabel()
Answer the label of this blank node or throw an UnsupportedOperationException if it's not blank.Graph
getGraph()
Get the graph for a graph term (N3 formula), otherwise die horriblyjava.lang.Object
getIndexingValue()
Answer the object which is the index value for this Node.LiteralLabel
getLiteral()
Answer the literal value of a literal node, or throw an UnsupportedOperationException if it's not a literal nodeRDFDatatype
getLiteralDatatype()
Answer the RDF datatype object of this node's literal value, if it is a literal; otherwise die horribly.java.lang.String
getLiteralDatatypeURI()
Answer the data-type URI of this node's literal value, if it is a literal; otherwise die horribly.boolean
getLiteralIsXML()
java.lang.String
getLiteralLanguage()
Answer the language of this node's literal value, if it is a literal; otherwise die horribly.java.lang.String
getLiteralLexicalForm()
Answer the lexical form of this node's literal value, if it is a literal; otherwise die horribly.java.lang.Object
getLiteralValue()
Answer the value of this node's literal value, if it is a literal; otherwise die horribly.java.lang.String
getLocalName()
get the localname part of this node if it's a URI node, else die horriblyjava.lang.String
getName()
get a variable nodes name, otherwise die horriblyjava.lang.String
getNameSpace()
get the namespace part of this node if it's a URI node, else die horriblyTriple
getTriple()
Get the triple for a triple term (embedded triple), otherwise die horriblyjava.lang.String
getURI()
get the URI of this node if it has one, else die horriblyint
hashCode()
boolean
hasURI(java.lang.String uri)
answer true iff this node is a URI node with the given URIboolean
isBlank()
Answer true iff this node is a blank node [subclasses override]abstract boolean
isConcrete()
Answer true iff this node is concrete, ie not variable, ie URI, blank, or literal.boolean
isExt()
Extension node.boolean
isLiteral()
Answer true iff this node is a literal node [subclasses override]boolean
isNodeGraph()
Answer true iff this node is an "graph node" (N3 formula).boolean
isNodeTriple()
Answer true iff this node is an "triple node" (RDF-star)boolean
isURI()
Answer true iff this node is a URI node [subclasses override]boolean
isVariable()
Answer true iff this node is a variable node - subclasses overrideboolean
matches(Node other)
Answer true iff this node accepts the other one as a match.boolean
sameValueAs(java.lang.Object o)
Test that two nodes are semantically equivalent.java.lang.String
toString()
Answer a human-readable representation of this Node.java.lang.String
toString(boolean quoting)
Answer a human-readable representation of this Node where literals are quoted according toquoting
but URIs are not compressed.java.lang.String
toString(PrefixMapping pm)
Answer a human-readable representation of the Node, quoting literals and compressing URIs.java.lang.String
toString(PrefixMapping pm, boolean quoting)
Answer a human readable representation of this Node, quoting literals if specified, and compressing URIs using the prefix mapping supplied.abstract java.lang.Object
visitWith(NodeVisitor v)
Visit a Node and dispatch on it to the appropriate method from the NodeVisitorv
.
-
-
-
Field Detail
-
ANY
public static final Node ANY
The canonical instance of Node_ANY. No other instances are required.
-
-
Method Detail
-
visitWith
public abstract java.lang.Object visitWith(NodeVisitor v)
Visit a Node and dispatch on it to the appropriate method from the NodeVisitorv
.- Parameters:
v
- the visitor to apply to the node- Returns:
- the value returned by the applied method
-
isConcrete
public abstract boolean isConcrete()
Answer true iff this node is concrete, ie not variable, ie URI, blank, or literal.
-
isLiteral
public boolean isLiteral()
Answer true iff this node is a literal node [subclasses override]
-
isBlank
public boolean isBlank()
Answer true iff this node is a blank node [subclasses override]
-
isURI
public boolean isURI()
Answer true iff this node is a URI node [subclasses override]
-
isVariable
public boolean isVariable()
Answer true iff this node is a variable node - subclasses override
-
isNodeTriple
public boolean isNodeTriple()
Answer true iff this node is an "triple node" (RDF-star)
-
isNodeGraph
public boolean isNodeGraph()
Answer true iff this node is an "graph node" (N3 formula). This is not related to named graphs.
-
isExt
public boolean isExt()
Extension node. Typically used in data structures based on triples.
-
getBlankNodeId
public BlankNodeId getBlankNodeId()
get the blank node id if the node is blank, otherwise die horribly
-
getBlankNodeLabel
public java.lang.String getBlankNodeLabel()
Answer the label of this blank node or throw an UnsupportedOperationException if it's not blank.
-
getLiteral
public LiteralLabel getLiteral()
Answer the literal value of a literal node, or throw an UnsupportedOperationException if it's not a literal node
-
getLiteralValue
public java.lang.Object getLiteralValue()
Answer the value of this node's literal value, if it is a literal; otherwise die horribly.
-
getLiteralLexicalForm
public java.lang.String getLiteralLexicalForm()
Answer the lexical form of this node's literal value, if it is a literal; otherwise die horribly.
-
getLiteralLanguage
public java.lang.String getLiteralLanguage()
Answer the language of this node's literal value, if it is a literal; otherwise die horribly.
-
getLiteralDatatypeURI
public java.lang.String getLiteralDatatypeURI()
Answer the data-type URI of this node's literal value, if it is a literal; otherwise die horribly.
-
getLiteralDatatype
public RDFDatatype getLiteralDatatype()
Answer the RDF datatype object of this node's literal value, if it is a literal; otherwise die horribly.
-
getLiteralIsXML
public boolean getLiteralIsXML()
-
getIndexingValue
public java.lang.Object getIndexingValue()
Answer the object which is the index value for this Node. The default is this Node itself; overridden in Node_Literal for literal indexing purposes. Only concrete nodes should use this method.
-
getURI
public java.lang.String getURI()
get the URI of this node if it has one, else die horribly
-
getNameSpace
public java.lang.String getNameSpace()
get the namespace part of this node if it's a URI node, else die horribly
-
getLocalName
public java.lang.String getLocalName()
get the localname part of this node if it's a URI node, else die horribly
-
getName
public java.lang.String getName()
get a variable nodes name, otherwise die horribly
-
getTriple
public Triple getTriple()
Get the triple for a triple term (embedded triple), otherwise die horribly
-
getGraph
public Graph getGraph()
Get the graph for a graph term (N3 formula), otherwise die horribly
-
hasURI
public boolean hasURI(java.lang.String uri)
answer true iff this node is a URI node with the given URI
-
equals
public abstract boolean equals(java.lang.Object o)
Nodes only equal other Nodes that have equal labels.- Overrides:
equals
in classjava.lang.Object
-
sameValueAs
public boolean sameValueAs(java.lang.Object o)
Test that two nodes are semantically equivalent. In some cases this may be the same as equals, in others equals is stricter. For example, two xsd:int literals with the same value but different lexical form are semantically equivalent but distinguished by the java equals function.Default implementation is to use equals, subclasses should override this.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
matches
public boolean matches(Node other)
Answer true iff this node accepts the other one as a match. The default is an equality test; it is over-ridden in subclasses to provide the appropriate semantics for literals, ANY, and variables.- Parameters:
other
- a node to test for matching- Returns:
- true iff this node accepts the other as a match
-
toString
public java.lang.String toString()
Answer a human-readable representation of this Node. It will not compress URIs, nor quote literals (because at the moment too many places use toString() for something machine-oriented).- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(boolean quoting)
Answer a human-readable representation of this Node where literals are quoted according toquoting
but URIs are not compressed.
-
toString
public java.lang.String toString(PrefixMapping pm)
Answer a human-readable representation of the Node, quoting literals and compressing URIs.
-
toString
public java.lang.String toString(PrefixMapping pm, boolean quoting)
Answer a human readable representation of this Node, quoting literals if specified, and compressing URIs using the prefix mapping supplied.
-
-