public static <T> NodeMapper<T> from(Class<T> clazz, TypeMapper typeMapper) { RDFDatatype dtype = typeMapper.getTypeByClass(clazz); NodeMapper<T> result = new NodeMapperRdfDatatype<>(dtype); return result; } }
public static Node createTypedLiteral(TypeMapper typeMapper, Object o) { Class<?> clazz = o.getClass(); RDFDatatype dtype = typeMapper.getTypeByClass(clazz); String lex = dtype.unparse(o); Node result = NodeFactory.createLiteral(lex, dtype); return result; }
protected RdfType allocateRdfType(Class<?> clazz) { RDFDatatype dtype = typeMapper.getTypeByClass(clazz); boolean isPrimitive = dtype != null; RdfType result; if(isPrimitive) { result = new RdfTypeLiteralTyped(this, dtype); } else { result = allocateRdfClass(clazz); } return result; }
public static <T> Literal createTypedLiteral(Model model, Class<T> clazz, T o) { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dtype = tm.getTypeByClass(clazz); Literal result = model.createTypedLiteral((Object)o, dtype); return result; }
protected RdfType allocateRdfType(Class<?> clazz) { RDFDatatype dtype = typeMapper.getTypeByClass(clazz); boolean isPrimitive = dtype != null; RdfType result; if(isPrimitive) { result = new RdfTypeLiteralTyped(this, dtype); } else { result = allocateRdfClass(clazz); } return result; }
RDFDatatype dtype = typeMapper.getTypeByClass(paramType);
@Override public NodeValue exec(List<NodeValue> args) { NodeValue result = NodeValue.nvNothing; NodeValue haystack = args.get(0); NodeValue needle = args.get(1); NodeValue limit = args.size() > 2 ? args.get(2) : null; int l = limit == null || limit.isInteger() ? -1 : limit.getInteger().intValue(); if(haystack.isString() && needle.isString()) { RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); String h = haystack.getString(); String n = needle.getString(); String[] strs = h.split(n, l); JsonArray arr = new JsonArray(); for(String str : strs) { arr.add(str); } Node node = NodeFactory.createLiteralByValue(arr, jsonDatatype); result = NodeValue.makeNode(node); } return result; }
result = p -> s -> new SetFromPropertyValues<>(s, p, rdfType); } else { RDFDatatype dtype = typeMapper.getTypeByClass(returnType); RDFDatatype dtype = typeMapper.getTypeByClass(returnType);
@Override public NodeValue exec(List<NodeValue> args) { NodeValue result = NodeValue.nvNothing; NodeValue haystack = args.get(0); NodeValue needle = args.get(1); NodeValue limit = args.size() > 2 ? args.get(2) : null; int l = limit == null || limit.isInteger() ? -1 : limit.getInteger().intValue(); if(haystack.isString() && needle.isString()) { RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); String h = haystack.getString(); String n = needle.getString(); String[] strs = h.split(n, l); JsonArray arr = new JsonArray(); for(String str : strs) { arr.add(str); } Node node = NodeFactory.createLiteralByValue(arr, jsonDatatype); result = NodeValue.makeNode(node); } return result; }
public static <T> T getLiteralValue(Statement stmt, Class<T> clazz) { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dtype = tm.getTypeByClass(clazz); RDFNode o = stmt.getObject(); T result = NodeMapperRdfDatatype.toJavaCore(o.asNode(), dtype); return result; }
RDFDatatype dt = tm.getTypeByClass(value.getClass());
@Override public NodeValue exec(NodeValue nv, NodeValue query) { RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); JsonElement json = asJson(nv); NodeValue result; if(query.isString() && json != null) { Object tmp = gson.fromJson(json, Object.class); //JsonTransformerObject.toJava.apply(json); String queryStr = query.getString(); try { // If parsing the JSON fails, we return nothing, yet we log an error Object o = JsonPath.read(tmp, queryStr); Node node = jsonToNode(o, gson, jsonDatatype); result = NodeValue.makeNode(node); } catch(Exception e) { logger.warn(e.getLocalizedMessage()); result = NodeValue.nvNothing; } } else { result = NodeValue.nvNothing; } return result; } }
RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); Node jsonNode = NodeFactory.createLiteral(str, jsonDatatype); result = NodeValue.makeNode(jsonNode);
@Override public NodeValue exec(NodeValue nv, NodeValue query) { RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); JsonElement json = asJson(nv); NodeValue result; if(query.isString() && json != null) { Object tmp = gson.fromJson(json, Object.class); //JsonTransformerObject.toJava.apply(json); String queryStr = query.getString(); try { // If parsing the JSON fails, we return nothing, yet we log an error Object o = JsonPath.read(tmp, queryStr); Node node = jsonToNode(o, gson, jsonDatatype); result = NodeValue.makeNode(node); } catch(Exception e) { logger.warn(e.getLocalizedMessage()); result = NodeValue.nvNothing; } } else { result = NodeValue.nvNothing; } return result; } }
RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); Node jsonNode = NodeFactory.createLiteral(str, jsonDatatype); result = NodeValue.makeNode(jsonNode);
public static boolean canAsLiteral(Statement stmt, Class<?> clazz) { TypeMapper tm = TypeMapper.getInstance(); RDFDatatype dtype = tm.getTypeByClass(clazz); RDFNode o = stmt.getObject(); boolean result = dtype != null && o.isLiteral() && NodeMapperRdfDatatype.canMapCore(o.asNode(), dtype); return result; }
RDFDatatype xmlDatatype = TypeMapper.getInstance().getTypeByClass(org.w3c.dom.Node.class); Objects.requireNonNull(xmlDatatype);
RDFDatatype xmlDatatype = TypeMapper.getInstance().getTypeByClass(org.w3c.dom.Node.class); Objects.requireNonNull(xmlDatatype);
public static Binding itemToBinding(Binding binding, JsonArray arr, int i, Gson gson, Var indexVar, Var outputVar) { JsonElement item; try { item = arr.get(i); } catch(Exception e) { throw new ExprEvalException(e); } RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); Node n = E_JsonPath.jsonToNode(item, gson, jsonDatatype); NodeValue nv = NodeValue.makeNode(n); Binding b = BindingFactory.binding(binding, outputVar, nv.asNode()); if(indexVar != null) { b = BindingFactory.binding(b, indexVar, NodeValue.makeInteger(i).asNode()); } return b; } }
public static Binding itemToBinding(Binding binding, JsonArray arr, int i, Gson gson, Var indexVar, Var outputVar) { JsonElement item; try { item = arr.get(i); } catch(Exception e) { throw new ExprEvalException(e); } RDFDatatype jsonDatatype = TypeMapper.getInstance().getTypeByClass(JsonElement.class); Node n = E_JsonPath.jsonToNode(item, gson, jsonDatatype); NodeValue nv = NodeValue.makeNode(n); Binding b = BindingFactory.binding(binding, outputVar, nv.asNode()); if(indexVar != null) { b = BindingFactory.binding(b, indexVar, NodeValue.makeInteger(i).asNode()); } return b; } }