/** * Same as {@code getAsString(path, null)} */ default String getAsString(String path) { return getAsString(path, null); }
private static String toSqlOp(ChildFilter.Op op) { switch(op) { case EQ: return " = "; case NEQ: return " <> "; case LT: return " < "; case GT: return " > "; case LTE: return " <= "; case GTE: return " >= "; default: throw new JsonDBException("Invalid filter comparison operation."); } }
default void getAsStream(String path, OutputStream os) { getAsStream(path, null, os); }
public static SqlExpressionBuilder create(SqlJsonDB db, Filter filter, String path) { if( filter instanceof ChildFilter ) { ChildFilter childFilter = (ChildFilter) filter; return create(db, childFilter, path); } if( filter instanceof LogicalFilter) { LogicalFilter logicalFilter = (LogicalFilter) filter; return create(db, logicalFilter, path); } throw new JsonDBException("Unsupported filter: "+filter); }
/** * Creates or Replaces the object or value at the given path * with the supplied json document. * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void set(String path, String json) { set(path, json.getBytes(StandardCharsets.UTF_8)); }
/** * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void update(String path, String json) { update(path, json.getBytes(StandardCharsets.UTF_8)); }
public void deletePodLogState(String podName) throws IOException { jsonDB.delete("/logs/pods/" + podName); }
default byte[] getAsByteArray(String path) { return getAsByteArray(path, null); }
default Consumer<OutputStream> getAsStreamingOutput(String path) { return getAsStreamingOutput(path, null); }
/** * Pushes a new value to the the requested path. * Same as: {@code set( path + "/" + createKey(), json)} * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct * @return the field name that was added to the path object */ default String push(String path, String json) { return push(path, json.getBytes(StandardCharsets.UTF_8)); }
@Override public String toString() { try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new JsonDBException(e); } } };
/** * Creates or Replaces the object or value at the given path * with the supplied json document. * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void set(String path, String json) { set(path, json.getBytes(StandardCharsets.UTF_8)); }
/** * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct */ default void update(String path, String json) { update(path, json.getBytes(StandardCharsets.UTF_8)); }
default byte[] getAsByteArray(String path) { return getAsByteArray(path, null); }
/** * Same as {@code getAsString(path, null)} */ default String getAsString(String path) { return getAsString(path, null); }
default void getAsStream(String path, OutputStream os) { getAsStream(path, null, os); }
default Consumer<OutputStream> getAsStreamingOutput(String path) { return getAsStreamingOutput(path, null); }
/** * Pushes a new value to the the requested path. * Same as: {@code set( path + "/" + createKey(), json)} * * @param path to the object or value to set * @param json value to set it to, can be a json primitive or struct * @return the field name that was added to the path object */ default String push(String path, String json) { return push(path, json.getBytes(StandardCharsets.UTF_8)); }
/** * @param path - the object or value to get * @param options options that control formatting of the result. * @return the json result or null if the path does not exist */ default String getAsString(String path, GetOptions options) { byte[] data = getAsByteArray(path, options); if( data==null ) { return null; } return new String(data, StandardCharsets.UTF_8); }
default byte[] getAsByteArray(String path, GetOptions options) { @SuppressWarnings("resource") ByteArrayOutputStream os = new ByteArrayOutputStream(); if( !getAsStream(path, options, os) ) { return null; } return os.toByteArray(); }