Package org.aksw.jenax.arq.util.node
Class NodeUtils
java.lang.Object
org.aksw.jenax.arq.util.node.NodeUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.jena.graph.Nodestatic final Stringstatic final org.apache.jena.riot.out.NodeFormatterstatic final StringPlaceholder constants to denote a 'null' node - the absence of a valuestatic final org.apache.jena.graph.Nodestatic final Stringstatic final Stringstatic final StringConstants for use withgetDatatypeIri(Node)Conflates the term type into a datatype: Under this perspective, IRIs and blank nodes are simply literals with the rr:IRI or rr:BlankNode datatype.static final org.apache.jena.riot.out.NodeFormatter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.jena.graph.NodeanyToNull(org.apache.jena.graph.Node n) static intcompareAlways(org.apache.jena.graph.Node o1, org.apache.jena.graph.Node o2) Compare nodes viaNodeValue.compareAlways(NodeValue, NodeValue)static org.apache.jena.graph.NodecreateGraphNode(String graphName) Returns the default graph for null or a blank string or 'default' (inoring case), otherwise creates an IRI from the argumentstatic List<org.apache.jena.graph.Node>createLiteralNodes(Iterable<String> strings) static org.apache.jena.graph.NodecreateTypedLiteral(org.apache.jena.datatypes.TypeMapper typeMapper, Object o) Create a typed literal for a java object by consulting jena's type mapperstatic org.apache.jena.graph.NodecreateUriOrNull(String uri) static List<org.apache.jena.graph.Node>static Set<org.apache.jena.graph.Node>getBnodesMentioned(Iterable<org.apache.jena.graph.Node> nodes) Filter an iterable of nodes to the set of contained bnodesstatic StringgetDatatypeIri(org.apache.jena.graph.Node node) Return a Node's datatype.static StringgetIriOrNull(org.apache.jena.graph.Node node) If the argument is an IRI-node return the IRI - otherwise return null.static StringgetIriOrString(org.apache.jena.graph.Node node) static StringgetLang(org.apache.jena.graph.Node node) Return the language of a node or null if the argument is not applicablestatic NumbergetNumber(org.apache.jena.graph.Node node) static NumbergetNumberNullable(org.apache.jena.graph.Node node) static StringgetUnquotedForm(org.apache.jena.graph.Node node) Returns the "unquoted form" of any Node depending on its type: null → "" literal → node.getLiteralLexicalForm() iri → node.getURI() bnode → node.getBlankNodeLabel() variable → node.getName() otherwise → NodeFmtLib.displayStr(node)static Set<org.apache.jena.sparql.core.Var>getVarsMentioned(Iterable<org.apache.jena.graph.Node> nodes) Filter an iterable of nodes to the set of contained variablesstatic inthashCode(org.apache.jena.graph.Node node) Util method for use a sparql function -static booleanisNullOrAny(org.apache.jena.graph.Node node) static booleanstatic booleanisValid(org.apache.jena.graph.Node node) Serialize and deserialize (print/parse) a node.static org.apache.jena.graph.NodelogicalAnd(org.apache.jena.graph.Node pattern, org.apache.jena.graph.Node b) Create a logical conjunction of two nodes: - Node.ANY, null or a variable matches everything - If any argument matches everything return the other argument (convert null to ANY) - if both arguments are concrete nodes then return one if them if they are equal - otherwise return nullstatic org.apache.jena.graph.NodenullOrFluentToAny(org.apache.jena.graph.Node n) Method to canonicalize variables to Node.ANYstatic org.apache.jena.graph.NodenullOrVarToAny(org.apache.jena.graph.Node node) Similar tonullOrFluentToAny(Node)but specifically for variables.static org.apache.jena.graph.NodenullToAny(org.apache.jena.graph.Node n) Deprecated.static org.apache.jena.graph.NodeExpect the string to parse as a single node.static <C extends Collection<? super org.apache.jena.graph.Node>>
CparseNodes(String str, C segments) Parse a sequence of nodes into the provided collectionstatic booleanput(org.apache.jena.sparql.engine.binding.BindingBuilder builder, org.apache.jena.graph.Node nodeOrVar, org.apache.jena.graph.Node node) static StringstrNodesWithUndef(BiConsumer<org.apache.jena.atlas.io.IndentedWriter, org.apache.jena.graph.Node> output, org.apache.jena.graph.Node... nodes) Variant ofNodeFmtLib.strNodesNT(Node...)that yield nul as UNDEFstatic voidstatic voidvalidate(org.apache.jena.graph.Node node) Throws anIllegalArgumentExceptionifisValid(Node)returns false.
-
Field Details
-
ntFormatter
public static final org.apache.jena.riot.out.NodeFormatter ntFormatter -
ttlFormatter
public static final org.apache.jena.riot.out.NodeFormatter ttlFormatter -
nullUri
Placeholder constants to denote a 'null' node - the absence of a value- See Also:
-
nullUriNode
public static final org.apache.jena.graph.Node nullUriNode -
ANY_IRI_STR
- See Also:
-
ANY_IRI
public static final org.apache.jena.graph.Node ANY_IRI -
R2RML_NS
Constants for use withgetDatatypeIri(Node)Conflates the term type into a datatype: Under this perspective, IRIs and blank nodes are simply literals with the rr:IRI or rr:BlankNode datatype. This approach simplifies analytics for e.g. application in schema mapping- See Also:
-
R2RML_IRI
- See Also:
-
R2RML_BlankNode
- See Also:
-
-
Constructor Details
-
NodeUtils
public NodeUtils()
-
-
Method Details
-
hashCode
public static int hashCode(org.apache.jena.graph.Node node) Util method for use a sparql function -<java:org.aksw.jenax.arq.util.node#hashCode>(?x) -
compareAlways
public static int compareAlways(org.apache.jena.graph.Node o1, org.apache.jena.graph.Node o2) Compare nodes viaNodeValue.compareAlways(NodeValue, NodeValue) -
getBnodesMentioned
public static Set<org.apache.jena.graph.Node> getBnodesMentioned(Iterable<org.apache.jena.graph.Node> nodes) Filter an iterable of nodes to the set of contained bnodes -
getVarsMentioned
public static Set<org.apache.jena.sparql.core.Var> getVarsMentioned(Iterable<org.apache.jena.graph.Node> nodes) Filter an iterable of nodes to the set of contained variables -
isNullOrAny
public static boolean isNullOrAny(org.apache.jena.graph.Node node) -
nullToAny
Deprecated.Method now exists in Jena's NodeUtils. This method was private inTripleat least in jena 3.16 -
anyToNull
public static org.apache.jena.graph.Node anyToNull(org.apache.jena.graph.Node n) -
nullOrFluentToAny
public static org.apache.jena.graph.Node nullOrFluentToAny(org.apache.jena.graph.Node n) Method to canonicalize variables to Node.ANY -
nullOrVarToAny
public static org.apache.jena.graph.Node nullOrVarToAny(org.apache.jena.graph.Node node) Similar tonullOrFluentToAny(Node)but specifically for variables. -
logicalAnd
public static org.apache.jena.graph.Node logicalAnd(org.apache.jena.graph.Node pattern, org.apache.jena.graph.Node b) Create a logical conjunction of two nodes: - Node.ANY, null or a variable matches everything - If any argument matches everything return the other argument (convert null to ANY) - if both arguments are concrete nodes then return one if them if they are equal - otherwise return null -
getLang
Return the language of a node or null if the argument is not applicable- Parameters:
node-- Returns:
-
getIriOrNull
If the argument is an IRI-node return the IRI - otherwise return null. Argument may be null. -
getDatatypeIri
Return a Node's datatype. Thereby, IRIs are returned as rr:IRI and BlankNodes as rr:BlankNode Returns null for variables and unknown node types- Parameters:
node-
-
createTypedLiteral
public static org.apache.jena.graph.Node createTypedLiteral(org.apache.jena.datatypes.TypeMapper typeMapper, Object o) Create a typed literal for a java object by consulting jena's type mapper -
createUriOrNull
-
fromUris
-
createLiteralNodes
-
getNumberNullable
-
getNumber
-
strNodesWithUndef
public static String strNodesWithUndef(BiConsumer<org.apache.jena.atlas.io.IndentedWriter, org.apache.jena.graph.Node> output, org.apache.jena.graph.Node... nodes) Variant ofNodeFmtLib.strNodesNT(Node...)that yield nul as UNDEF -
parseNode
Expect the string to parse as a single node. -
parseNodes
public static <C extends Collection<? super org.apache.jena.graph.Node>> C parseNodes(String str, C segments) Parse a sequence of nodes into the provided collection -
createGraphNode
Returns the default graph for null or a blank string or 'default' (inoring case), otherwise creates an IRI from the argument -
isValid
public static boolean isValid(org.apache.jena.graph.Node node) Serialize and deserialize (print/parse) a node. Returns true iff the result is the same (term-equality) as the input. -
isValid
-
validate
public static void validate(org.apache.jena.graph.Node node) Throws anIllegalArgumentExceptionifisValid(Node)returns false. -
validate
-
put
public static boolean put(org.apache.jena.sparql.engine.binding.BindingBuilder builder, org.apache.jena.graph.Node nodeOrVar, org.apache.jena.graph.Node node) -
getIriOrString
-
getUnquotedForm
Returns the "unquoted form" of any Node depending on its type:- null → ""
- literal → node.getLiteralLexicalForm()
- iri → node.getURI()
- bnode → node.getBlankNodeLabel()
- variable → node.getName()
- otherwise → NodeFmtLib.displayStr(node)
-