com.hp.hpl.jena.graph
Class Node

java.lang.Object
  extended by com.hp.hpl.jena.graph.Node
Direct Known Subclasses:
Node_Concrete, Node_Fluid

public abstract class Node
extends Object

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.


Nested Class Summary
static class Node.NotLiteral
          Exception thrown if a literal-access operation is attemted on a non-literal node.
 
Field Summary
static Node ANY
          The canonical instance of Node_ANY.
static Node NULL
          The canonical NULL.
 
Method Summary
static Node create(com.hp.hpl.jena.graph.Node.NodeMaker maker, Object label)
          We object strongly to null labels: for example, they make .equals flaky.
static Node createAnon()
          Deprecated. Use NodeFactory.createAnon() instead
static Node createAnon(AnonId id)
          Deprecated. Use NodeFactory.createAnon(AnonId) instead
static Node createLiteral(com.hp.hpl.jena.graph.impl.LiteralLabel lit)
          Deprecated. Use NodeFactory.createLiteral(LiteralLabel) instead
static Node createLiteral(String value)
          Deprecated. Use NodeFactory.createLiteral(String) instead
static Node createLiteral(String lex, RDFDatatype dtype)
          Deprecated. Use NodeFactory.createLiteral(String,RDFDatatype) instead
static Node createLiteral(String lit, String lang, boolean isXml)
          Deprecated. Use NodeFactory.createLiteral(String,String,boolean) instead
static Node createLiteral(String lex, String lang, RDFDatatype dtype)
          Deprecated. Use NodeFactory.createLiteral(String,String,RDFDatatype) instead
static Node createUncachedLiteral(Object value, RDFDatatype dtype)
          Deprecated. Use NodeFactory.createUncachedLiteral(Object,RDFDatatype) instead
static Node createUncachedLiteral(Object value, String lang, RDFDatatype dtype)
          Deprecated. Use NodeFactory.createUncachedLiteral(Object,String,RDFDatatype) instead
static Node createURI(String uri)
          Deprecated. Use NodeFactory.createURI(String) instead
static Node createVariable(String name)
          Deprecated. Use NodeFactory.createVariable(String) instead
abstract  boolean equals(Object o)
          Nodes only equal other Nodes that have equal labels.
 AnonId getBlankNodeId()
          get the blank node id if the node is blank, otherwise die horribly
 String getBlankNodeLabel()
          Answer the label of this blank node or throw an UnsupportedOperationException if it's not blank.
 Object getIndexingValue()
          Answer the object which is the index value for this Node.
 com.hp.hpl.jena.graph.impl.LiteralLabel getLiteral()
          Answer the literal value of a literal node, or throw an UnsupportedOperationException if it's not a literal node
 RDFDatatype getLiteralDatatype()
          Answer the RDF datatype object of this node's literal value, if it is a literal; otherwise die horribly.
 String getLiteralDatatypeURI()
          Answer the data-type URI of this node's literal value, if it is a literal; otherwise die horribly.
 boolean getLiteralIsXML()
           
 String getLiteralLanguage()
          Answer the language of this node's literal value, if it is a literal; otherwise die horribly.
 String getLiteralLexicalForm()
          Answer the lexical form of this node's literal value, if it is a literal; otherwise die horribly.
 Object getLiteralValue()
          Answer the value of this node's literal value, if it is a literal; otherwise die horribly.
 String getLocalName()
          get the localname part of this node if it's a URI node, else die horribly
 String getName()
          get a variable nodes name, otherwise die horribly
 String getNameSpace()
          get the namespace part of this node if it's a URI node, else die horribly
static RDFDatatype getType(String s)
          Deprecated. Use NodeFactory.getType(String) instead
 String getURI()
          get the URI of this node if it has one, else die horribly
 int hashCode()
           
 boolean hasURI(String uri)
          answer true iff this node is a URI node with the given URI
 boolean 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 isLiteral()
          Answer true iff this node is a literal node [subclasses override]
 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 override
 boolean matches(Node other)
          Answer true iff this node accepts the other one as a match.
 boolean sameValueAs(Object o)
          Test that two nodes are semantically equivalent.
 String toString()
          Answer a human-readable representation of this Node.
 String toString(boolean quoting)
          Answer a human-readable representation of this Node where literals are quoted according to quoting but URIs are not compressed.
 String toString(PrefixMapping pm)
          Answer a human-readable representation of the Node, quoting literals and compressing URIs.
 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  Object visitWith(NodeVisitor v)
          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 Detail

ANY

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


NULL

public static final Node NULL
The canonical NULL. It appears here so that revised definitions [eg as a bnode] that require the cache-and-maker system will work; the NodeMaker constants should be non-null at this point.

Method Detail

getType

@Deprecated
public static RDFDatatype getType(String s)
Deprecated. Use NodeFactory.getType(String) instead


createAnon

@Deprecated
public static Node createAnon()
Deprecated. Use NodeFactory.createAnon() instead

make a blank node with a fresh anon id


createAnon

@Deprecated
public static Node createAnon(AnonId id)
Deprecated. Use NodeFactory.createAnon(AnonId) instead

make a blank node with the specified label


createLiteral

@Deprecated
public static Node createLiteral(com.hp.hpl.jena.graph.impl.LiteralLabel lit)
Deprecated. Use NodeFactory.createLiteral(LiteralLabel) instead

make a literal node with the specified literal value


createURI

@Deprecated
public static Node createURI(String uri)
Deprecated. Use NodeFactory.createURI(String) instead

make a URI node with the specified URIref string


createVariable

@Deprecated
public static Node createVariable(String name)
Deprecated. Use NodeFactory.createVariable(String) instead

make a variable node with a given name


createLiteral

@Deprecated
public static Node createLiteral(String value)
Deprecated. Use NodeFactory.createLiteral(String) instead


createLiteral

@Deprecated
public static Node createLiteral(String lit,
                                            String lang,
                                            boolean isXml)
Deprecated. Use NodeFactory.createLiteral(String,String,boolean) instead

make a literal with specified language and XMLishness. _lit_ must *not* be null.

Parameters:
isXml - If true then lit is exclusive canonical XML of type rdf:XMLLiteral, and no checking will be invoked.

createLiteral

@Deprecated
public static Node createLiteral(String lex,
                                            String lang,
                                            RDFDatatype dtype)
                          throws DatatypeFormatException
Deprecated. Use NodeFactory.createLiteral(String,String,RDFDatatype) instead

Build a literal node from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.

Parameters:
lex - the lexical form of the literal
lang - the optional language tag
dtype - the type of the literal, null for old style "plain" literals
Throws:
DatatypeFormatException - if lex is not a legal form of dtype

createLiteral

@Deprecated
public static Node createLiteral(String lex,
                                            RDFDatatype dtype)
                          throws DatatypeFormatException
Deprecated. Use NodeFactory.createLiteral(String,RDFDatatype) instead

Build a typed literal node from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.

Parameters:
lex - the lexical form of the literal
dtype - the type of the literal, null for old style "plain" literals
Throws:
DatatypeFormatException - if lex is not a legal form of dtype

createUncachedLiteral

@Deprecated
public static Node createUncachedLiteral(Object value,
                                                    String lang,
                                                    RDFDatatype dtype)
                                  throws DatatypeFormatException
Deprecated. Use NodeFactory.createUncachedLiteral(Object,String,RDFDatatype) instead

Throws:
DatatypeFormatException

createUncachedLiteral

@Deprecated
public static Node createUncachedLiteral(Object value,
                                                    RDFDatatype dtype)
                                  throws DatatypeFormatException
Deprecated. Use NodeFactory.createUncachedLiteral(Object,RDFDatatype) instead

Throws:
DatatypeFormatException

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, 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


getBlankNodeId

public AnonId getBlankNodeId()
get the blank node id if the node is blank, otherwise die horribly


getBlankNodeLabel

public String getBlankNodeLabel()
Answer the label of this blank node or throw an UnsupportedOperationException if it's not blank.


getLiteral

public com.hp.hpl.jena.graph.impl.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.


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.


getLiteralIsXML

public boolean getLiteralIsXML()

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


hasURI

public boolean hasURI(String uri)
answer true iff this node is a URI node with the given URI


create

public static Node create(com.hp.hpl.jena.graph.Node.NodeMaker maker,
                          Object label)
We object strongly to null labels: for example, they make .equals flaky.


equals

public abstract boolean equals(Object o)
Nodes only equal other Nodes that have equal labels.

Overrides:
equals in class Object

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 language tag are semantically equivalent but distinguished by the java equality function in order to support round-tripping.

Default implementation is to use equals, subclasses should override this.


hashCode

public 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

toString

public 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 class Object

toString

public String toString(boolean quoting)
Answer a human-readable representation of this Node where literals are quoted according to quoting but URIs are not compressed.


toString

public String toString(PrefixMapping pm)
Answer a human-readable representation of the Node, quoting literals and compressing URIs.


toString

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



Licenced under the Apache License, Version 2.0