Package com.adobe.aem.dermis.util
Class ValueUtil
- java.lang.Object
-
- com.adobe.aem.dermis.util.ValueUtil
-
public class ValueUtil extends java.lang.Object
Utility methods to ConstructIValue
based on JSON or Connector Property.
-
-
Constructor Summary
Constructors Constructor Description ValueUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce, boolean generateNullForPropsNotInData)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce, boolean generateNullForPropsNotInData)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValueMap
generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes)
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, boolean autoCoerce)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, boolean autoCoerce, boolean generateNullForPropsNotInData)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> dataModels, boolean autoCoerce, boolean generateNullForPropsNotInData)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static IValue
generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> dataModels, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes)
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution.static java.lang.Object
getFormattedValue(java.lang.Object value)
Return formatted value for provided input.static IValue
getValue(IValueMap valueMap, java.lang.String name)
Get the value object associated with a key.static IValueList
jsonListToValue(org.apache.sling.commons.json.JSONArray array)
Construct the value object based on the providedJSONArray
.static IValueMap
jsonObjectToValue(org.apache.sling.commons.json.JSONObject data)
Construct the value object based on the providedJSONObject
.static IValue
jsonToValue(java.lang.Object data)
Construct the value object based on the provided json object or array.static IValue
jsonToValue(java.lang.String jsonString, IProperty property)
Construct the value object based on the provided json string.
-
-
-
Method Detail
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, boolean autoCoerce) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to type- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type if fdmAdditionalData is present in input data and it contains type information, then mentioned type dataModel is used to construct value- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.datamodels
- - List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happenautoCoerce
- - boolean value represent to auto coerce the value according to type- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, boolean autoCoerce, boolean generateNullForPropsNotInData) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the output- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> dataModels, boolean autoCoerce, boolean generateNullForPropsNotInData) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type if fdmAdditionalData is present in input data and it contains type information, then mentioned type dataModel is used to construct value- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.dataModels
- - List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happenautoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the output- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the outputremoveComputedAttributes
- - boolean if this is true, computed attributes will be removed from the output- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValue generateValue(IProperty property, java.lang.Object data, java.util.List<? extends IDataModel> dataModels, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes) throws DermisException
Construct the value object according to providedProperty
and based on result (Java Object) of operation execution. if autoCoerce is false if any type/value is mismatched thenDermisExceptionCodes.PROPERTY_TYPE_MISS_MATCH
exception is thrown and if its true it will try to convert the value according to property type if fdmAdditionalData is present in input data and it contains type information, then mentioned type dataModel is used to construct value- Parameters:
property
- -Property
according to which value object is constructed.data
- - Result of operation execution.dataModels
- - List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happenautoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the outputremoveComputedAttributes
- - boolean if this is true, computed attributes will be removed from the output- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to type- Returns:
- Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typedatamodels
- - List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happen- Returns:
- Returns the
IValueMap
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce, boolean generateNullForPropsNotInData) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, child properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the output- Returns:
- Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce, boolean generateNullForPropsNotInData) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typedatamodels
- -List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happengenerateNullForPropsNotInData
- - boolean if this is true, child properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the output- Returns:
- Returns the
IValueMap
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.autoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, child properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the output- Returns:
- Returns the
IValueMap
representing the output of operation. - Throws:
DermisException
-
generateValue
public static IValueMap generateValue(IDataModel dataModel, java.util.Map<java.lang.String,java.lang.Object> data, java.util.List<? extends IDataModel> datamodels, boolean autoCoerce, boolean generateNullForPropsNotInData, boolean removeComputedAttributes) throws DermisException
Construct the value object according to providedDataModel
structured based on result (Java Object) of operation execution.- Parameters:
dataModel
- -DataModel
according to which value object is constructed.data
- - Result of operation execution.datamodels
- - List of datamodels to be used to resolve _type information present in data and construct value accordingly , if null no resolution will happenautoCoerce
- - boolean value represent to auto coerce the value according to typegenerateNullForPropsNotInData
- - boolean if this is true, child properties for which no value is present in data, are included in the output with value null. If value of this parameter is false, null valued properties are omitted entirely from the outputremoveComputedAttributes
- - boolean if this is true, computed attributes will be removed from the output- Returns:
- Throws:
DermisException
-
jsonToValue
public static IValue jsonToValue(java.lang.String jsonString, IProperty property) throws DermisException, org.apache.sling.commons.json.JSONException
Construct the value object based on the provided json string.- Parameters:
jsonString
- - input json string.- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
org.apache.sling.commons.json.JSONException
-
jsonToValue
public static IValue jsonToValue(java.lang.Object data) throws DermisException, org.apache.sling.commons.json.JSONException
Construct the value object based on the provided json object or array.- Parameters:
data
- - data representingJSONArray
orJSONObject
- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
org.apache.sling.commons.json.JSONException
-
jsonObjectToValue
public static IValueMap jsonObjectToValue(org.apache.sling.commons.json.JSONObject data) throws DermisException, org.apache.sling.commons.json.JSONException
Construct the value object based on the providedJSONObject
.- Parameters:
data
- - data representingJSONObject
- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
org.apache.sling.commons.json.JSONException
-
jsonListToValue
public static IValueList jsonListToValue(org.apache.sling.commons.json.JSONArray array) throws DermisException, org.apache.sling.commons.json.JSONException
Construct the value object based on the providedJSONArray
.- Parameters:
array
- - data representingJSONArray
- Returns:
- Returns the
IValue
representing the output of operation. - Throws:
DermisException
org.apache.sling.commons.json.JSONException
-
getFormattedValue
public static java.lang.Object getFormattedValue(java.lang.Object value)
Return formatted value for provided input. For date, it will return in ISO8601 format bytes, it will return base64 format of byte array. string and number are return in same format- Parameters:
value
- - input value to format.- Returns:
- - Return formatted value for provided input.
-
-