How formatters work with application logic layer entities

Toolkit application logic layer entities use the CHA Formatter Service to invoke formatters for converting data elements to formatted strings and to update data elements.

Following is a description of how the toolkit converts a context to a formatted string for the application logic layer entities:

  1. A toolkit application logic layer entity needs to convert a context into a string representation of the data element with a particular format. It calls the formatter facade and passes the context to it.
  2. The formatter facade then passes the context containing the name of the data element instance requiring conversion to the CHA Formatter Service. The CHA Formatter Service then invokes the appropriate formatter to convert the data element. An instance variable in the formatter instance stores the name of the data element that the formatter will convert.
  3. The formatter converts the data element into a string according to the formatter's definition.
  4. The formatter might call a decorator to apply additional formatting to the string.

Alternatively, if the toolkit application logic layer entity needs to update a context from a formatted string, the process is:

  1. A toolkit application logic layer entity needs to update a context from a formatted string.
  2. The toolkit application logic layer entity calls the formatter facade. The formatter facade passes the context and the string requiring unformat to the CHA Formatter Service.
  3. The CHA Formatter Service then initializes the formatter instance using an external definition.
  4. The formatter instance calls the unformat method of the formatter instance and passes the context and the string that requires parsing.
  5. The formatter extracts the substring from the passed string.
  6. If the formatter is a decorator, the format removes the decoration.
  7. The formatter parses the substring.
  8. The formatter the updates the context with the results of parsing the substring.