Class Node

java.lang.Object
org.apache.jena.graph.Node
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Node_ANY, Node_Blank, Node_Ext, Node_Graph, Node_Literal, Node_Triple, Node_URI, Node_Variable

public abstract class Node extends Object implements Serializable
A Node has subtypes:

Nodes should be constructed by the NodeFactory methods.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Exception thrown if a literal-access operation is attempted on a non-literal node.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Node
    The canonical instance of Node_ANY.
    static final String
    The string used when a literal does not have a language tag.
    static final TextDirection
    The TextDirection used when a literal does not have an initial text direction setting.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    Java rules for equals.
    Answer the label of this blank node or throw an UnsupportedOperationException if it's not blank.
    Get the graph for a graph term (N3 formula), otherwise die horribly
    Answer the object which is the index value for this Node.
    Answer the literal value of a literal node, or throw an UnsupportedOperationException if it's not a literal node
    Answer the RDF datatype object of this node's literal value, if it is a literal; otherwise die horribly.
    Answer the data-type URI of this node's literal value, if it is a literal; otherwise die horribly.
    Answer the language of this node's literal value, if it is a literal; otherwise die horribly.
    Answer the lexical form of this node's literal value, if it is a literal; otherwise die horribly.
    Return the initial text direction for an rdf:dirLangString literal.
    Answer the value of this node's literal value, if it is a literal; otherwise die horribly.
    get the localname part of this node if it's a URI node, else die horribly
    get a variable nodes name, otherwise die horribly
    get the namespace part of this node if it's a URI node, else die horribly
    Get the triple for a triple term (embedded triple), otherwise die horribly
    get the URI of this node if it has one, else die horribly
    abstract int
     
    boolean
    answer true iff this node is a URI node with the given URI
    boolean
    Answer true iff this node is a blank node [subclasses override]
    abstract boolean
    Answer true iff this node is concrete, meaning a node that is data in an RDF Graph.
    boolean
    Extension node.
    boolean
    Answer true iff this node is a literal node [subclasses override]
    boolean
    Answer true iff this node is an "graph node" (N3 formula).
    boolean
    Answer true iff this node is an "triple node" (RDF-star)
    boolean
    Answer true iff this node is a URI node [subclasses override]
    boolean
    Answer true iff this node is a variable node - subclasses override
    boolean
    matches(Node other)
    Answer true iff this node accepts the other one as a match.
    boolean
     
    boolean
    Test that two nodes are semantically equivalent.
    abstract String
    Answer a human-readable representation of this Node.
    abstract String
    Answer a human-readable representation of the Node.
    abstract Object
    Visit a Node and dispatch on it to the appropriate method from the NodeVisitor v.

    Methods inherited from class java.lang.Object

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

    • ANY

      public static final Node ANY
      The canonical instance of Node_ANY. No other instances are required.
    • noLangTag

      public static final String noLangTag
      The string used when a literal does not have a language tag. Accessing the language of a non-literal will throw an exception.
      See Also:
    • noTextDirection

      public static final TextDirection noTextDirection
      The TextDirection used when a literal does not have an initial text direction setting. Accessing the initial text direction of a non-literal will throw an exception.
      See Also:
  • Method Details

    • visitWith

      public abstract Object visitWith(NodeVisitor v)
      Visit a Node and dispatch on it to the appropriate method from the NodeVisitor v.
      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, meaning a node that is data in an RDF Graph.
    • 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.
    • getBlankNodeLabel

      public 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 Object getLiteralValue()
      Answer the value of this node's literal value, if it is a literal; otherwise die horribly.
    • getLiteralLexicalForm

      public String getLiteralLexicalForm()
      Answer the lexical form of this node's literal value, if it is a literal; otherwise die horribly.
    • getLiteralLanguage

      public String getLiteralLanguage()
      Answer the language of this node's literal value, if it is a literal; otherwise die horribly.
    • getLiteralTextDirection

      public TextDirection getLiteralTextDirection()
      Return the initial text direction for an rdf:dirLangString literal. Does not return null if the literal is a rdf:dirLangString literal. Returns null if the text direction is not set (and the datatype won't be rdf:dirLangString). Otherwise die horribly.
    • getLiteralDatatypeURI

      public 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.
    • getIndexingValue

      public 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 String getURI()
      get the URI of this node if it has one, else die horribly
    • getNameSpace

      public String getNameSpace()
      get the namespace part of this node if it's a URI node, else die horribly
    • getLocalName

      public String getLocalName()
      get the localname part of this node if it's a URI node, else die horribly
    • getName

      public 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(String uri)
      answer true iff this node is a URI node with the given URI
    • equals

      public abstract boolean equals(Object o)
      Java rules for equals. See also {#sameTermAs} and {#sameValueAs} Nodes only equal other Nodes that have equal labels.
      Overrides:
      equals in class Object
    • sameTermAs

      public boolean sameTermAs(Object o)
    • sameValueAs

      public boolean sameValueAs(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.

    • toString

      public abstract String toString()
      Answer a human-readable representation of this Node.
      Overrides:
      toString in class Object
    • toString

      public abstract String toString(PrefixMapping pmap)
      Answer a human-readable representation of the Node. For URIs, abbreviate URI. For literals, quoting literals and abbreviating datatype URI.
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class 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