Class JenaJsonUtils
java.lang.Object
org.aksw.jena_sparql_api.sparql.ext.json.JenaJsonUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.jena.sparql.expr.NodeValuestatic org.apache.jena.sparql.expr.NodeValueconvertJsonOrValueToNodeValue(Object o, com.google.gson.Gson gson) If the argument is of primitive java datatype then return a Node with corresponding xsd type.static StringconvertJsonOrValueToString(Object o, com.google.gson.Gson gson) toString for primitive Java objects or JsonElementsstatic org.apache.jena.sparql.expr.NodeValueconvertJsonToNodeValue(com.google.gson.JsonElement e) static org.apache.jena.graph.NodecreateLiteralByValue(com.google.gson.JsonElement json) static com.google.gson.JsonElementenforceJsonElement(org.apache.jena.sparql.expr.NodeValue nv) Extract or convertstatic org.apache.jena.sparql.expr.NodeValueevalJsonPath(com.google.gson.Gson gson, org.apache.jena.sparql.expr.NodeValue nv, org.apache.jena.sparql.expr.NodeValue query) static com.google.gson.JsonElementextractChecked(org.apache.jena.graph.Node node) Extract a JsonElement from the given node.static com.google.gson.JsonElementextractChecked(org.apache.jena.sparql.expr.NodeValue nv) static com.google.gson.JsonElementextractJsonElementOrNull(org.apache.jena.sparql.expr.NodeValue nv) static com.google.gson.JsonObjectextractJsonObjectOrNull(org.apache.jena.graph.Node node) static com.google.gson.JsonElementextractOrNull(org.apache.jena.graph.Node node) static NumberfindNearestNumber(com.google.gson.JsonPrimitive p) static org.apache.jena.sparql.expr.NodeValuefromString(String jsonStr) static booleanstatic booleanisJsonElement(org.apache.jena.sparql.expr.NodeValue nv) static org.apache.jena.sparql.engine.binding.BindingitemToBinding(org.apache.jena.sparql.engine.binding.Binding binding, com.google.gson.JsonArray arr, int i, com.google.gson.Gson gson, org.apache.jena.sparql.core.Var indexVar, org.apache.jena.sparql.core.Var outputVar) static org.apache.jena.sparql.expr.NodeValuemakeJsonNodeValue(org.apache.jena.graph.Node node) static org.apache.jena.sparql.expr.NodeValuemakeNodeValue(com.google.gson.JsonElement json) static com.google.gson.JsonElementnodeLiteralToJsonElement(org.apache.jena.graph.Node node) static com.google.gson.JsonElementnodeToJsonElement(org.apache.jena.graph.Node node) static com.google.gson.JsonElementrequireJsonElement(org.apache.jena.sparql.expr.NodeValue nv) Use this method in SPARQL evaluation; Raises an ExprTypeException on incorrect argument.static org.apache.jena.sparql.engine.QueryIteratorunnestJsonArray(com.google.gson.Gson gson, org.apache.jena.sparql.engine.binding.Binding binding, org.apache.jena.graph.Node index, org.apache.jena.sparql.engine.ExecutionContext execCxt, org.apache.jena.graph.Node node, org.apache.jena.sparql.core.Var outputVar)
-
Constructor Details
-
JenaJsonUtils
public JenaJsonUtils()
-
-
Method Details
-
extractJsonObjectOrNull
public static com.google.gson.JsonObject extractJsonObjectOrNull(org.apache.jena.graph.Node node) -
extractOrNull
public static com.google.gson.JsonElement extractOrNull(org.apache.jena.graph.Node node) -
extractChecked
public static com.google.gson.JsonElement extractChecked(org.apache.jena.graph.Node node) Extract a JsonElement from the given node. Returns null for a null argument. If the argument is not a literal or does not hold a json object anIllegalArgumentExceptionis raised.- Parameters:
node-- Returns:
-
extractChecked
public static com.google.gson.JsonElement extractChecked(org.apache.jena.sparql.expr.NodeValue nv) -
requireJsonElement
public static com.google.gson.JsonElement requireJsonElement(org.apache.jena.sparql.expr.NodeValue nv) Use this method in SPARQL evaluation; Raises an ExprTypeException on incorrect argument. -
extractJsonElementOrNull
public static com.google.gson.JsonElement extractJsonElementOrNull(org.apache.jena.sparql.expr.NodeValue nv) -
isJsonElement
public static boolean isJsonElement(org.apache.jena.sparql.expr.NodeValue nv) -
makeJsonNodeValue
public static org.apache.jena.sparql.expr.NodeValue makeJsonNodeValue(org.apache.jena.graph.Node node) -
enforceJsonElement
public static com.google.gson.JsonElement enforceJsonElement(org.apache.jena.sparql.expr.NodeValue nv) Extract or convert -
nodeToJsonElement
public static com.google.gson.JsonElement nodeToJsonElement(org.apache.jena.graph.Node node) -
nodeLiteralToJsonElement
public static com.google.gson.JsonElement nodeLiteralToJsonElement(org.apache.jena.graph.Node node) -
convertJsonOrValueToNodeValue
-
convertJsonOrValueToNodeValue
public static org.apache.jena.sparql.expr.NodeValue convertJsonOrValueToNodeValue(Object o, com.google.gson.Gson gson) If the argument is of primitive java datatype then return a Node with corresponding xsd type. If the argument is of primitive json then return a Node with the corresponding xsd type. If the argument is non-primitive JSON then return a Node with json type from it In any other case attempt to convert the argument to json (via gson). -
isJavaJsonPrimitive
-
convertJsonOrValueToString
toString for primitive Java objects or JsonElements -
convertJsonToNodeValue
public static org.apache.jena.sparql.expr.NodeValue convertJsonToNodeValue(com.google.gson.JsonElement e) -
findNearestNumber
-
evalJsonPath
public static org.apache.jena.sparql.expr.NodeValue evalJsonPath(com.google.gson.Gson gson, org.apache.jena.sparql.expr.NodeValue nv, org.apache.jena.sparql.expr.NodeValue query) -
unnestJsonArray
public static org.apache.jena.sparql.engine.QueryIterator unnestJsonArray(com.google.gson.Gson gson, org.apache.jena.sparql.engine.binding.Binding binding, org.apache.jena.graph.Node index, org.apache.jena.sparql.engine.ExecutionContext execCxt, org.apache.jena.graph.Node node, org.apache.jena.sparql.core.Var outputVar) -
itemToBinding
public static org.apache.jena.sparql.engine.binding.Binding itemToBinding(org.apache.jena.sparql.engine.binding.Binding binding, com.google.gson.JsonArray arr, int i, com.google.gson.Gson gson, org.apache.jena.sparql.core.Var indexVar, org.apache.jena.sparql.core.Var outputVar) -
fromString
-
createLiteralByValue
public static org.apache.jena.graph.Node createLiteralByValue(com.google.gson.JsonElement json) -
makeNodeValue
public static org.apache.jena.sparql.expr.NodeValue makeNodeValue(com.google.gson.JsonElement json)
-