Class JenaJsonUtils

java.lang.Object
org.aksw.jena_sparql_api.sparql.ext.json.JenaJsonUtils

public class JenaJsonUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.jena.sparql.expr.NodeValue
     
    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.
    static String
    convertJsonOrValueToString(Object o, com.google.gson.Gson gson)
    toString for primitive Java objects or JsonElements
    static org.apache.jena.sparql.expr.NodeValue
    convertJsonToNodeValue(com.google.gson.JsonElement e)
     
    static org.apache.jena.graph.Node
    createLiteralByValue(com.google.gson.JsonElement json)
     
    static com.google.gson.JsonElement
    enforceJsonElement(org.apache.jena.sparql.expr.NodeValue nv)
    Extract or convert
    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)
     
    static com.google.gson.JsonElement
    extractChecked(org.apache.jena.graph.Node node)
    Extract a JsonElement from the given node.
    static com.google.gson.JsonElement
    extractChecked(org.apache.jena.sparql.expr.NodeValue nv)
     
    static com.google.gson.JsonElement
    extractJsonElementOrNull(org.apache.jena.sparql.expr.NodeValue nv)
     
    static com.google.gson.JsonObject
    extractJsonObjectOrNull(org.apache.jena.graph.Node node)
     
    static com.google.gson.JsonElement
    extractOrNull(org.apache.jena.graph.Node node)
     
    static Number
    findNearestNumber(com.google.gson.JsonPrimitive p)
     
    static org.apache.jena.sparql.expr.NodeValue
    fromString(String jsonStr)
     
    static boolean
     
    static boolean
    isJsonElement(org.apache.jena.sparql.expr.NodeValue nv)
     
    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)
     
    static org.apache.jena.sparql.expr.NodeValue
    makeJsonNodeValue(org.apache.jena.graph.Node node)
     
    static org.apache.jena.sparql.expr.NodeValue
    makeNodeValue(com.google.gson.JsonElement json)
     
    static com.google.gson.JsonElement
    nodeLiteralToJsonElement(org.apache.jena.graph.Node node)
     
    static com.google.gson.JsonElement
    nodeToJsonElement(org.apache.jena.graph.Node node)
     
    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.
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 an IllegalArgumentException is 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

      public static org.apache.jena.sparql.expr.NodeValue convertJsonOrValueToNodeValue(Object o)
    • 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

      public static boolean isJavaJsonPrimitive(Object o)
    • convertJsonOrValueToString

      public static String convertJsonOrValueToString(Object o, com.google.gson.Gson gson)
      toString for primitive Java objects or JsonElements
    • convertJsonToNodeValue

      public static org.apache.jena.sparql.expr.NodeValue convertJsonToNodeValue(com.google.gson.JsonElement e)
    • findNearestNumber

      public static Number findNearestNumber(com.google.gson.JsonPrimitive p)
    • 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

      public static org.apache.jena.sparql.expr.NodeValue fromString(String jsonStr)
    • 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)