Addresses and the AddressFormatter class
The AddressFormatter class is used to convert addresses to localized strings for display as read-only address information. If you change, add, or delete columns of the Address entity, you must also update this class. Additionally, if you add a new country definition, you might need to update the switch statement in the internalFormat method of this class.
There are two types of addresses in PolicyCenter:
- Synchronized
- Unsynchronized
Unsynchronized addresses apply to policy location addresses and policy addresses. An address is unsynchronized if the following are all true:
- The address is part of a completed job (a promoted branch).
- The associated account location address has changed since the job was completed.
Unsynchronized addresses are read-only. There are several ways to handle this situation:
- Expand the unsynchronized address definition in the PCF to apply to the entire address. Currently, PolicyCenter does not treat the street address portion of the PCF as either synchronized or unsynchronized.
- Format the display string by using the gw.address.AddressFormatter class.
PolicyCenter displays read-only address information in several different places. PolicyCenter displays read-only address information as a string in which the address values are separated by commas or by line-feeds. PolicyCenter uses class gw.address.AddressFormatter to manage and format read-only strings.
The AddressFormatter class consists of two parts:
- The class contains variables for all the address columns. You can extend the class to add new variables if you extend the Address entity with new columns.
- The class contains two
versions of the format
method with different signatures.
The method parameters have the following meanings:
Parameter |
Description |
|---|---|
|
The address to format. |
|
Use this delimiter to separate the various string elements. If the delimiter is a comma, then the method also adds a space after the comma. |
|
The set of fields to include in the address. |
PolicyCenter calls class AddressFormatter from the following places:
- From
entity.Address.DisplayName. Use the Entity Names editor to modify the address string definition. - From the
Address.addressString
method, defined in enhancement
AddressEnhancement - From the
PolicyLocation.addressString
method, defined in enhancement
PolicyLocationEnhancement - From the
PolicyAddress.addressString
method, defined in enhancement
PolicyAddressEnhancement
Each of these uses creates a new AddressFormatter instance, populates
the variables, and then returns AddressFormatter.addressString.
In particular:
Address.DisplayNamealways passes the same parameters. The other three uses just pass through the three parameters that they receive. This method always return a comma-delimited address string. However, this method is simpler to use because it requires no additional parameters.Address.addressStringis the more general form of usage with an address, especially if the delimiter value is something other than a comma.PolicyLocation.addressStringandPolicyAddress.addressStringwork in the same manner as the Address.addressString method, except that they pass in the internally enhanced values for the address values. Other code in these enhancements determines whether to use the associated address values, or the internal values.
See also
