return new TextNode(new String(Base64.encodeBase64(out.toByteArray()), Charsets.UTF_8)); } else if (object instanceof Boolean) { return BooleanNode.valueOf((Boolean) object); } else if (object instanceof String) { return new TextNode((String) object);
@Override public JsonNode serialize(Boolean object) { return BooleanNode.valueOf(object); }
public Atom(boolean value) { this(BooleanNode.valueOf(value), null); }
public BooleanLiteral(final boolean value) { super(BooleanNode.valueOf(value)); } }
public BooleanLiteral(final boolean value) { super(BooleanNode.valueOf(value)); } }
public Atom(boolean value, long expires) { this(BooleanNode.valueOf(value), expires); }
public Record set(String key, boolean v) { map.set(key, BooleanNode.valueOf(v)); return this; }
@Override public List<JsonNode> apply(Scope scope, List<JsonQuery> args, JsonNode in) throws JsonQueryException { return Collections.singletonList(BooleanNode.valueOf(predicate.test(in))); } }
@Override public List<JsonNode> apply(Scope scope, List<JsonQuery> args, JsonNode in) throws JsonQueryException { return Collections.singletonList(BooleanNode.valueOf(predicate.test(in))); } }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { return Collections.<JsonNode> singletonList(BooleanNode.valueOf(!JsonNodeUtils.asBoolean(in))); } }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { return Collections.<JsonNode> singletonList(BooleanNode.valueOf(!JsonNodeUtils.asBoolean(in))); } }
@Override public List<JsonNode> apply(Scope scope, List<JsonQuery> args, JsonNode in) throws JsonQueryException { Preconditions.checkInputType("startswith", in, JsonNodeType.STRING); final String text = in.asText(); final List<JsonNode> out = new ArrayList<>(); for (final JsonNode prefix : args.get(0).apply(scope, in)) { if (!prefix.isTextual()) throw new JsonQueryException("1st argument of startswith() must evaluate to string"); out.add(BooleanNode.valueOf(text.startsWith(prefix.asText()))); } return out; } }
@Override public List<JsonNode> apply(Scope scope, List<JsonQuery> args, JsonNode in) throws JsonQueryException { Preconditions.checkInputType("startswith", in, JsonNodeType.STRING); final String text = in.asText(); final List<JsonNode> out = new ArrayList<>(); for (final JsonNode prefix : args.get(0).apply(scope, in)) { if (!prefix.isTextual()) throw new JsonQueryException("1st argument of startswith() must evaluate to string"); out.add(BooleanNode.valueOf(text.startsWith(prefix.asText()))); } return out; } }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { Preconditions.checkInputType("endswith", in, JsonNodeType.STRING); final String text = in.asText(); final List<JsonNode> out = new ArrayList<>(); for (final JsonNode suffix : args.get(0).apply(scope, in)) { if (!suffix.isTextual()) throw new JsonQueryException("1st argument of endswith() must evaluate to string"); out.add(BooleanNode.valueOf(text.endsWith(suffix.asText()))); } return out; } }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { Preconditions.checkInputType("endswith", in, JsonNodeType.STRING); final String text = in.asText(); final List<JsonNode> out = new ArrayList<>(); for (final JsonNode suffix : args.get(0).apply(scope, in)) { if (!suffix.isTextual()) throw new JsonQueryException("1st argument of endswith() must evaluate to string"); out.add(BooleanNode.valueOf(text.endsWith(suffix.asText()))); } return out; } }
@Override public JsonNode apply(ObjectMapper mapper, JsonNode lhs, JsonNode rhs) throws JsonQueryException { final int r = comparator.compare(lhs, rhs); return BooleanNode.valueOf(test(r)); }
@Override public JsonNode apply(ObjectMapper mapper, JsonNode lhs, JsonNode rhs) throws JsonQueryException { final int r = comparator.compare(lhs, rhs); return BooleanNode.valueOf(test(r)); }
@Override public List<JsonNode> apply(final Scope scope, final JsonNode in) throws JsonQueryException { final List<JsonNode> out = new ArrayList<>(); for (final JsonNode l : lhs.apply(scope, in)) { if (JsonNodeUtils.asBoolean(l)) { out.add(BooleanNode.TRUE); continue; } for (final JsonNode r : rhs.apply(scope, in)) out.add(BooleanNode.valueOf(JsonNodeUtils.asBoolean(r))); } return out; } }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { final List<JsonNode> out = new ArrayList<>(); for (final JsonNode value : args.get(0).apply(scope, in)) { if (in.getNodeType() != value.getNodeType() || (in.isBoolean() && in.asBoolean() != value.asBoolean())) { throw JsonQueryTypeException.format("%s (%s) and %s (%s) cannot have their containment checked", in.getNodeType(), in, value.getNodeType(), value); } out.add(BooleanNode.valueOf(contains(value, in))); } return out; }
@Override public List<JsonNode> apply(final Scope scope, final List<JsonQuery> args, final JsonNode in) throws JsonQueryException { final List<JsonNode> out = new ArrayList<>(); for (final JsonNode value : args.get(0).apply(scope, in)) { if (in.getNodeType() != value.getNodeType() || (in.isBoolean() && in.asBoolean() != value.asBoolean())) { throw JsonQueryTypeException.format("%s (%s) and %s (%s) cannot have their containment checked", in.getNodeType(), in, value.getNodeType(), value); } out.add(BooleanNode.valueOf(contains(value, in))); } return out; }