use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class LessThanJSONObjectFilter method matchesJSONObject.
/**
* {@inheritDoc}
*/
@Override()
public boolean matchesJSONObject(@NotNull final JSONObject o) {
final List<JSONValue> candidates = getValues(o, field);
if (candidates.isEmpty()) {
return false;
}
for (final JSONValue v : candidates) {
if (v instanceof JSONArray) {
boolean matchOne = false;
boolean matchAll = true;
for (final JSONValue arrayValue : ((JSONArray) v).getValues()) {
if (matches(arrayValue)) {
if (!matchAllElements) {
return true;
}
matchOne = true;
} else {
matchAll = false;
if (matchAllElements) {
break;
}
}
}
if (matchAllElements && matchOne && matchAll) {
return true;
}
} else if (matches(v)) {
return true;
}
}
return false;
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class NegateJSONObjectFilter method toJSONObject.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONObject toJSONObject() {
final LinkedHashMap<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(2));
fields.put(FIELD_FILTER_TYPE, new JSONString(FILTER_TYPE));
fields.put(FIELD_NEGATE_FILTER, negateFilter.toJSONObject());
return new JSONObject(fields);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class ObjectMatchesJSONObjectFilter method toJSONObject.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONObject toJSONObject() {
final LinkedHashMap<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(3));
fields.put(FIELD_FILTER_TYPE, new JSONString(FILTER_TYPE));
if (field.size() == 1) {
fields.put(FIELD_FIELD_PATH, new JSONString(field.get(0)));
} else {
final ArrayList<JSONValue> fieldNameValues = new ArrayList<>(field.size());
for (final String s : field) {
fieldNameValues.add(new JSONString(s));
}
fields.put(FIELD_FIELD_PATH, new JSONArray(fieldNameValues));
}
fields.put(FIELD_FILTER, filter.toJSONObject());
return new JSONObject(fields);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class ANDJSONObjectFilter method toJSONObject.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONObject toJSONObject() {
final LinkedHashMap<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(2));
fields.put(FIELD_FILTER_TYPE, new JSONString(FILTER_TYPE));
final ArrayList<JSONValue> filterValues = new ArrayList<>(andFilters.size());
for (final JSONObjectFilter f : andFilters) {
filterValues.add(f.toJSONObject());
}
fields.put(FIELD_AND_FILTERS, new JSONArray(filterValues));
return new JSONObject(fields);
}
use of com.unboundid.util.json.JSONValue in project ldapsdk by pingidentity.
the class ContainsFieldJSONObjectFilter method toJSONObject.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONObject toJSONObject() {
final LinkedHashMap<String, JSONValue> fields = new LinkedHashMap<>(StaticUtils.computeMapCapacity(3));
fields.put(FIELD_FILTER_TYPE, new JSONString(FILTER_TYPE));
if (field.size() == 1) {
fields.put(FIELD_FIELD_PATH, new JSONString(field.get(0)));
} else {
final ArrayList<JSONValue> fieldNameValues = new ArrayList<>(field.size());
for (final String s : field) {
fieldNameValues.add(new JSONString(s));
}
fields.put(FIELD_FIELD_PATH, new JSONArray(fieldNameValues));
}
if (!expectedValueTypes.equals(ALL_EXPECTED_VALUE_TYPES)) {
if (expectedValueTypes.size() == 1) {
fields.put(FIELD_EXPECTED_TYPE, new JSONString(expectedValueTypes.iterator().next().toString()));
} else {
final ArrayList<JSONValue> expectedTypeValues = new ArrayList<>(expectedValueTypes.size());
for (final ExpectedValueType t : expectedValueTypes) {
expectedTypeValues.add(new JSONString(t.toString()));
}
fields.put(FIELD_EXPECTED_TYPE, new JSONArray(expectedTypeValues));
}
}
return new JSONObject(fields);
}
Aggregations