java.lang.Object
org.apache.jena.sparql.util.NodeUtils
Node utilities.
See
NodeCmp
for node comparison operations.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic EqualityTest
Both null or same node :Node.equals
static EqualityTest
Term comparison.static EqualityTest
sameValue by SPARQL rules -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.jena.graph.Node
IRI string to Nodestatic List<org.apache.jena.graph.Node>
convertToListNodes
(String... namedGraphs) Convert strings to a List ofNodes
.static List<org.apache.jena.graph.Node>
convertToListNodes
(List<String> namedGraphs) Convert strings to a List ofNodes
.static Set<org.apache.jena.graph.Node>
convertToSetNodes
(String... namedGraphs) Convert a collection of strings to a set ofNodes
.static Set<org.apache.jena.graph.Node>
convertToSetNodes
(Collection<String> namedGraphs) Convert a collection of strings to a set ofNodes
.static boolean
hasLang
(org.apache.jena.graph.Node node) Return true if the node is a literal and has a language tag.static boolean
hasLangDir
(org.apache.jena.graph.Node node) Return true if the node is a literal and has an base directionstatic boolean
isDirLangString
(org.apache.jena.graph.Node n) A Node is a language string if it has a language tag.static boolean
isLangString
(org.apache.jena.graph.Node n) A Node is a language string if it has a language tag.static boolean
isSimpleString
(org.apache.jena.graph.Node n) A Node is a simple string if: (RDF 1.0) No datatype and no language tag (RDF 1.1) xsd:stringstatic boolean
isValidAsRDF
(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Determines whether a triple (as s/p/o) is valid as a RDF statement.static boolean
isValidAsRDF
(org.apache.jena.graph.Node g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Determines whether a quad (as g/s/p/o) is valid as a RDF statement.static boolean
isXSDNumeric
(org.apache.jena.graph.Node node) Return true if the node is a literal and has an XSD numeric datatype.nodesToURIs
(Iterator<org.apache.jena.graph.Node> iter) Convert IRI Nodes to strings.static org.apache.jena.graph.Node
nullToAny
(org.apache.jena.graph.Node n) static StreamRDF
Filter out triples and quads that are "generalized" RDFstatic String
stringLiteral
(org.apache.jena.graph.Node literal) Get lexical form of anything that looks like a string literal.
-
Field Details
-
sameNode
Both null or same node :Node.equals
-
sameRdfTerm
Term comparison. Node.equals or lang tags are case insensitive -
sameValue
sameValue by SPARQL rules
-
-
Constructor Details
-
NodeUtils
public NodeUtils()
-
-
Method Details
-
asNode
IRI string to Node -
hasLang
public static boolean hasLang(org.apache.jena.graph.Node node) Return true if the node is a literal and has a language tag. It may be a rdf:langString or rdf:dirLangString. -
hasLangDir
public static boolean hasLangDir(org.apache.jena.graph.Node node) Return true if the node is a literal and has an base direction -
stringLiteral
Get lexical form of anything that looks like a string literal. Returns the string value of plain literal (simple literal or lang string) or XSD string. -
nullToAny
public static org.apache.jena.graph.Node nullToAny(org.apache.jena.graph.Node n) -
nodesToURIs
Convert IRI Nodes to strings. Skip other kinds of Node -
convertToSetNodes
Convert a collection of strings to a set ofNodes
. -
convertToSetNodes
Convert a collection of strings to a set ofNodes
. -
convertToListNodes
Convert strings to a List ofNodes
. -
convertToListNodes
Convert strings to a List ofNodes
. -
isXSDNumeric
public static boolean isXSDNumeric(org.apache.jena.graph.Node node) Return true if the node is a literal and has an XSD numeric datatype. -
isSimpleString
public static boolean isSimpleString(org.apache.jena.graph.Node n) A Node is a simple string if:- (RDF 1.0) No datatype and no language tag
- (RDF 1.1) xsd:string
-
isLangString
public static boolean isLangString(org.apache.jena.graph.Node n) A Node is a language string if it has a language tag. (RDF 1.0 and RDF 1.1) -
isDirLangString
public static boolean isDirLangString(org.apache.jena.graph.Node n) A Node is a language string if it has a language tag. (RDF 1.0 and RDF 1.1) -
isValidAsRDF
public static boolean isValidAsRDF(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Determines whether a triple (as s/p/o) is valid as a RDF statement.This function reflects the fact that the
Triple
API is flexible in allowing any Node type in any position (including non-RDF node types like Variable) and as such not all Triples can be safely converted into Statements- Parameters:
s
- Subjectp
- Predicateo
- Object- Returns:
- True if a valid as a statement
-
isValidAsRDF
public static boolean isValidAsRDF(org.apache.jena.graph.Node g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Determines whether a quad (as g/s/p/o) is valid as a RDF statement.This function reflects the fact that the
Triple
API is flexible in allowing any Node type in any position (including non-RDF node types like Variable) and as such not all Triples can be safely converted into Statements- Parameters:
s
- Subjectp
- Predicateo
- Object- Returns:
- True if a valid as a statement
-
removeGeneralizedRDF
Filter out triples and quads that are "generalized" RDF
-