Modifier and Type | Class and Description |
---|---|
static class |
JsonValuePropertyEvaluator.CoercionFunctionSpec
The specification for a coercion function.
|
static class |
JsonValuePropertyEvaluator.CoercionFunctionSpecBuilder
Builder to create a
JsonValuePropertyEvaluator.CoercionFunctionSpec . |
Constructor and Description |
---|
JsonValuePropertyEvaluator(SubstitutionService substitutionService,
List<JsonValuePropertyEvaluator.CoercionFunctionSpec> coercionFunctions)
Constructs a JsonValuePropertyEvaluator which traverses a
JsonValue and does property
substitution as well as type coercion. |
Modifier and Type | Method and Description |
---|---|
static JsonValuePropertyEvaluator.CoercionFunctionSpecBuilder |
coerce(Predicate<JsonValue> predicate)
Define a coercion function.
|
JsonValue |
evaluate(JsonValue object,
boolean escape)
Traverses a
JsonValue and does property substitution as well as any type coercion. |
JsonValue |
evaluate(JsonValue object,
SubstitutionContext context)
Traverses a
JsonValue and does property substitution as well as any type coercion. |
static JsonValuePropertyEvaluator.CoercionFunctionSpec |
inlineCoercionFunction(Path relativeTo)
Creates a coercion function that inlines the content of another file that may be a relative path to a current
location.
|
static Predicate<JsonValue> |
singleKeyWithName(String name)
Create a predicate for a JSON coercion function as used in the
Map argument to
JsonValuePropertyEvaluator.JsonValuePropertyEvaluator(SubstitutionService, List) . |
public JsonValuePropertyEvaluator(SubstitutionService substitutionService, List<JsonValuePropertyEvaluator.CoercionFunctionSpec> coercionFunctions)
JsonValue
and does property
substitution as well as type coercion.
Custom coercion functions can be added to the additionalCoercionFunctions map. Custom functions should
Be a function that takes a value like
{ "properties" : { "$yourKey" : "your_object_stringified" } }and transforms it into
{ "properties" : your_transformed_object }
coercionFunctions
- Any additional type coercion functions in addition to the standard functionssubstitutionService
- The SubstitutionService
to use to do property substitution.public static JsonValuePropertyEvaluator.CoercionFunctionSpec inlineCoercionFunction(Path relativeTo)
For example, given this content at /tmp/mycontent:
Content that is too large to be written directly into a JSON file. e.g. email templateThe this format:
{ "attribute" : { "$inline" : "/tmp/mycontent" } }would be converted into this
{ "attribute" : "Content that is too large to be\nwritten directly into a JSON file\ne.g. email template" }
relativeTo
- The path that the inlined file will be resolved from, if it is not absolute.public static JsonValuePropertyEvaluator.CoercionFunctionSpecBuilder coerce(Predicate<JsonValue> predicate)
predicate
- The predicate that will match JSON that can be coerced.public static Predicate<JsonValue> singleKeyWithName(String name)
Map
argument to
JsonValuePropertyEvaluator.JsonValuePropertyEvaluator(SubstitutionService, List)
.name
- The name of the coercion function.JsonValue
predicate.public JsonValue evaluate(JsonValue object, boolean escape) throws SubstitutionException
JsonValue
and does property substitution as well as any type coercion.object
- The JsonValue
to traverseescape
- If true the SubstitutionService.substitute(String, boolean)
method will support
escaping. If false the SubstitutionService.substitute(String, boolean)
method
will NOT support escapingSubstitutionException
- when substitution is interrupted because of an error (unresolved var or cycle)public JsonValue evaluate(JsonValue object, SubstitutionContext context) throws SubstitutionException
JsonValue
and does property substitution as well as any type coercion.object
- The JsonValue
to traversecontext
- The SubstitutionContext
to use when evaluating the properties for substitutionSubstitutionException
- when substitution is interrupted because of an error (unresolved var or cycle)Copyright © 2010-2018, ForgeRock All Rights Reserved.