Modifier and Type | Method and Description |
---|---|
static Class<?> |
asClass(org.forgerock.json.fluent.JsonValue value)
Returns the class object associated with a named class or interface, using the thread
context class loader.
|
static Expression |
asExpression(org.forgerock.json.fluent.JsonValue value)
Returns a JSON value string value as an expression.
|
static <T> T |
asNewInstance(org.forgerock.json.fluent.JsonValue value,
Class<T> type)
Creates a new instance of a named class.
|
static void |
checkJsonCompatibility(String trail,
Object value)
Verify that the given parameter object is of a JSON compatible type (recursively).
|
static String |
evaluate(org.forgerock.json.fluent.JsonValue value)
Evaluates the given JSON value string as an
Expression . |
static org.forgerock.json.fluent.JsonValue |
evaluateJsonStaticExpression(org.forgerock.json.fluent.JsonValue value)
Evaluates the given JSON value using an Expression and wraps the returned value as a new JsonValue.
|
static org.forgerock.json.fluent.JsonValue |
getWithDeprecation(org.forgerock.json.fluent.JsonValue config,
Logger logger,
String name,
String... deprecatedNames)
Returns the named property from the provided JSON object, falling back to
zero or more deprecated property names.
|
static <T extends Enum<T>> |
ofEnum(Class<T> enumType)
Returns a
Function to transform a list of String-based JsonValue s into a list of enum
constant values of the given type. |
static org.forgerock.util.promise.Function<org.forgerock.json.fluent.JsonValue,Expression,HeapException> |
ofExpression()
Returns a function for transforming JsonValues to expressions.
|
static <T> org.forgerock.util.promise.Function<org.forgerock.json.fluent.JsonValue,T,HeapException> |
ofRequiredHeapObject(Heap heap,
Class<T> type)
Returns a
Function to transform a list of String-based JsonValue s into a list of required heap
objects. |
static <T> T |
readJson(Reader reader)
Parses to json the provided reader.
|
static <T> T |
readJson(String rawData)
Parses to json the provided data.
|
static Map<String,Object> |
readJsonLenient(InputStream in)
This function it's only used to read our configuration files and allows
JSON files to contain non strict JSON such as comments or single quotes.
|
static Map<String,Object> |
readJsonLenient(Reader reader)
This function it's only used to read our configuration files and allows
JSON files to contain non strict JSON such as comments or single quotes.
|
static void |
warnForDeprecation(org.forgerock.json.fluent.JsonValue config,
Logger logger,
String name,
String deprecatedName)
Issues a warning that the configuration property
oldName is
deprecated and that the property newName should be used instead. |
static byte[] |
writeJson(Object objectToWrite)
Writes the JSON content of the object passed in parameter.
|
public static Class<?> asClass(org.forgerock.json.fluent.JsonValue value)
null
, this method returns null
.value
- the value containing the class name string.org.forgerock.json.fluent.JsonValueException
- if value is not a string or the named class could not be found.public static <T> T asNewInstance(org.forgerock.json.fluent.JsonValue value, Class<T> type)
new
expression with an empty argument list. The class is initialized if it has
not already been initialized. If the value is null
, this method returns
null
.T
- the type of the new instance.value
- the value containing the class name string.type
- the type that the instantiated class should to resolve to.org.forgerock.json.fluent.JsonValueException
- if the requested class could not be instantiated.public static Expression asExpression(org.forgerock.json.fluent.JsonValue value)
null
, this
method returns null
.value
- the JSON value containing the expression string.org.forgerock.json.fluent.JsonValueException
- if the value is not a string or the value is not a valid expression.public static String evaluate(org.forgerock.json.fluent.JsonValue value)
Expression
.value
- the JSON value containing the expression string.org.forgerock.json.fluent.JsonValueException
- if the value is not a string or the value is not a valid string typed expression.public static org.forgerock.json.fluent.JsonValue evaluateJsonStaticExpression(org.forgerock.json.fluent.JsonValue value)
value
- the JSON value to be evaluated.org.forgerock.json.fluent.JsonException
- if the expression cannot be evaluated (syntax error or resolution error).public static org.forgerock.util.promise.Function<org.forgerock.json.fluent.JsonValue,Expression,HeapException> ofExpression()
public static <T> org.forgerock.util.promise.Function<org.forgerock.json.fluent.JsonValue,T,HeapException> ofRequiredHeapObject(Heap heap, Class<T> type)
Function
to transform a list of String-based JsonValue
s into a list of required heap
objects.T
- expected object typeheap
- the heap to query for references resolutiontype
- expected object typeFunction
to transform a list of String-based JsonValue
s into a list of required heap
objects.public static <T extends Enum<T>> org.forgerock.util.promise.Function<org.forgerock.json.fluent.JsonValue,T,HeapException> ofEnum(Class<T> enumType)
Function
to transform a list of String-based JsonValue
s into a list of enum
constant values of the given type.T
- Enumeration typeenumType
- expected type of the enumFunction
to transform a list of String-based JsonValue
s into a list of enum
constant values of the given type.public static void checkJsonCompatibility(String trail, Object value)
trail
- pointer to the verified objectvalue
- object to verifypublic static org.forgerock.json.fluent.JsonValue getWithDeprecation(org.forgerock.json.fluent.JsonValue config, Logger logger, String name, String... deprecatedNames)
config
- The configuration object.logger
- The logger which should be used for deprecation warnings.name
- The non-deprecated property name.deprecatedNames
- The deprecated property names ordered from newest to oldest.public static void warnForDeprecation(org.forgerock.json.fluent.JsonValue config, Logger logger, String name, String deprecatedName)
oldName
is
deprecated and that the property newName
should be used instead.config
- The configuration object.logger
- The logger which should be used for deprecation warnings.name
- The non-deprecated property name.deprecatedName
- The deprecated property name.public static <T> T readJson(String rawData) throws IOException
T
- The parsing should be as specified in doc. e.g:rawData
- The data as a string to read and parse.IOException
- If an exception occurs during parsing the data.readJson(Reader)
public static <T> T readJson(Reader reader) throws IOException
T
- The parsing should be as specified in doc. e.g:
JSON | Type Java Type ------------------------------------ object | LinkedHashMaparray | LinkedList> string | String number | Integer float | Float true|false | Boolean null | null
reader
- The data to parse.IOException
- If an exception occurs during parsing the data.public static Map<String,Object> readJsonLenient(Reader reader) throws IOException
reader
- The stream of data to parse.IOException
- If an error occurs during reading/parsing the data.public static Map<String,Object> readJsonLenient(InputStream in) throws IOException
in
- The input stream containing the json configuration.IOException
- If an error occurs during reading/parsing the data.public static byte[] writeJson(Object objectToWrite) throws IOException
objectToWrite
- The object we want to serialize as JSON output. TheIOException
- If an error occurs during writing/mapping content.Copyright © 2014 ForgeRock AS. All rights reserved.