KeyInformation¶
- public final class KeyInformation¶
Object representation of dragged field from trigger or data source.
This class represents a single dragged field from trigger or data source. This class does not expose a public constructor. You have to use parse(String) method if you want to parse single field or parseAll(String) if you want ot get all fields from a given string.
Methods¶
fromAdditionalData¶
- public boolean fromAdditionalData()¶
Check if the field is from the data source.
Returns: true if the field is from the data source otherwise false
fromTrigger¶
- public boolean fromTrigger()¶
Check if the field is from the trigger.
Returns: true if the field is from the trigger otherwise false
getManipulations¶
getOriginalKey¶
hasManipulations¶
- public boolean hasManipulations()¶
Check if the field has any manipulations.
Returns: true if the field has manipulations otherwise false
parse¶
- public static KeyInformation parse(String input)¶
Parse given string to instance of KeyInformation.
This method should be used to convert string representation of dragged field to instance of KeyInformation.
Argument has adhere to one of the following format:
- trigger field format: trigger.eventKey
- data source format: ad.dataProviderId.objectType#objectId.fieldKey
Argument can also contain list of manipulation which should be executed on field before it will be used by org.motechproject.tasks.service.TaskTriggerHandler class. Manipulations should be connected together by the ? character.
Example of input argument:
- ad.279f5fdf60700d9717270b1ae3011eb1.CaseInfo#0.fieldValues.phu_id
- trigger.message?format(Ala,cat)?capitalize
Parameters: - input – string representation of a dragged field from trigger or data source
Throws: - IllegalArgumentException – exception is thrown if format for data source field is incorrect or if the dragged field is not from trigger or data source.
Returns: Object representation of a dragged field
parseAll¶
- public static List<KeyInformation> parseAll(String input)¶
Find all fields from given input and convert them to the instance of KeyInformation.
This method should be used to find and convert all of string representation of the field from trigger and/or data sources. Fields in input have to adhere to one of the following formats:
- trigger field format: {{trigger.eventKey}}
- data source format: {{ad.dataProviderId.objectType#objectId.fieldKey}}
To find fields in the input argument this method uses regular expression. When field is found it is converted to an instance of KeyInformation by using the parse(String) method.
Fields are found by the following regular expression: {{((.*?))(}})(?![^(]*)). The expression searches for strings that start with {{ and end with }} and are not within ( and ). Because of manipulations which contain additional data in (...) needed to execute manipulation on the field (e.g.: join needs to have the join character) and the text in (...) can be another string representation of the dragged field, the expression has to check if the field has this kind of manipulation.
Example of input argument:
- {{trigger.message?format(Ala,cat)?capitalize}}
- You get the following message: {{trigger.message}}
Parameters: - input – string with one or more string representation of dragged fields from trigger and/or data sources
Throws: - IllegalArgumentException – in the same situations as the parse(String) method.
Returns: list of object representation of dragged fields.