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.



public static final String ADDITIONAL_DATA_PREFIX

Prefix which is used for data source fields.


public static final String TRIGGER_PREFIX

Prefix which is used for trigger fields.



public boolean equals(Object obj)


public boolean fromAdditionalData()

Check if the field is from the data source.

Returns:true if the field is from the data source otherwise false


public boolean fromTrigger()

Check if the field is from the trigger.

Returns:true if the field is from the trigger otherwise false


public Long getDataProviderId()


public String getKey()


public List<String> getManipulations()

Get manipulations assigned to the field.

Returns:list of manipulations


public Long getObjectId()


public String getObjectType()


public String getOriginalKey()

Get original representation of the dragged field.

Returns:string representation of the field


public String getPrefix()


public boolean hasManipulations()

Check if the field has any manipulations.

Returns:true if the field has manipulations otherwise false


public int hashCode()


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
  • input – string representation of a dragged field from trigger or data source
  • IllegalArgumentException – exception is thrown if format for data source field is incorrect or if the dragged field is not from trigger or data source.

Object representation of a dragged field


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}}
  • input – string with one or more string representation of dragged fields from trigger and/or data sources

list of object representation of dragged fields.