Record Class JsonPathEvaluator.Limits
java.lang.Object
java.lang.Record
ca.marcusdunn.jsonlens.path.evaluator.JsonPathEvaluator.Limits
- Record Components:
maxNodes- the maximum number of nodes in a nodelistmaxRegexSize- the maximum number of program instructions for a regular expression
- Enclosing class:
JsonPathEvaluator
Resource limits. When an evaluation passes a limit, the result is an overflow indication (RFC 9535, Section 2.1), not a wrong result.
| Limit | Error when the evaluation passes it |
|---|---|
maxNodes() |
EvaluationError.NodelistTooLarge |
maxRegexSize() |
EvaluationError.RegexTooComplex |
JsonPathEvaluator strict = JsonPathEvaluator.standard()
.withLimits(new JsonPathEvaluator.Limits(5, 1_000)); // at most 5 nodes in a nodelist
String outcome = switch (strict.evaluate(query("$[*]"), root, JacksonJsonModel.INSTANCE)) {
case Result.Ok(List<Node<JsonNode>> nodes) -> nodes.size() + " nodes";
case Result.Err(EvaluationError.NodelistTooLarge(int limit)) -> "more than " + limit + " nodes";
case Result.Err(EvaluationError.RegexTooComplex(String pattern, int limit)) -> "regexp too large: " + pattern;
case Result.Err(EvaluationError error) -> error.message();
};
// outcome: "more than 5 nodes"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsonPathEvaluator.Limits10,000,000 nodes and 10,000 regular expression instructions. -
Constructor Summary
ConstructorsConstructorDescriptionLimits(int maxNodes, int maxRegexSize) Creates an instance of aLimitsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intmaxNodes()Returns the value of themaxNodesrecord component.intReturns the value of themaxRegexSizerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT
10,000,000 nodes and 10,000 regular expression instructions.
-
-
Constructor Details
-
Limits
public Limits(int maxNodes, int maxRegexSize) Creates an instance of aLimitsrecord class.- Parameters:
maxNodes- the value for themaxNodesrecord componentmaxRegexSize- the value for themaxRegexSizerecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
maxNodes
-
maxRegexSize
public int maxRegexSize()Returns the value of themaxRegexSizerecord component.- Returns:
- the value of the
maxRegexSizerecord component
-