Retrieving Codes from Code Table Files

Since a code table file can contain any number of locales for a named code a mechanism needs to be in place to return the correctly localized code for a running instance of Cúram. Codes are retrieved from a code table file based on the locale property which includes a language and, optionally, a country. The code table file look up returns a matching localized code for a named value. For example, if the runtime locale is set to en_US where "en" is the language and "US" is the country, a code look up for the code named ACODE in the example below, will return the text "The code". If, however, the runtime locale was set to "fr", the text "Le code" would be returned.

Figure 1. Code File Search
<codetables package="curam.codetable">
  <codetable java_identifier="AN_ID" name="ANAME">
    <code default="true" java_identifier="ACODE"
          status="ENABLED" value="ACODE">
      <locale language="en" country="US" sort_order="0">
        <description>The code</description>
        <annotation></annotation>
      </locale>
      <locale language="en">
        <description>The en code</description>
        <annotation></annotation>
      </locale>
      <locale language="fr">
        <description>Le code</description>
        <annotation></annotation>
      </locale>
    </code>
  </codetable
</codetables>

Since code table files are not guaranteed to contain an entry for every country, a fall back mechanism is in place. Once a code of a given name has been found and there is no direct match with the specified locale, the rules for fall back are as follows:

For example, if the runtime locale is set to fr_CA, then the following will be the search path:

If nothing is found for either the runtime locale or the fallback locale of en, then an empty string is returned.