Different target platforms use different naming conventions. As a result you might not want to copy the names of your elements directly into the transformed models. To facilitate this requirement, Enterprise Architect's transformation templates provide a CONVERT_NAME function macro.
Another way in which you can transform a name is to remove a prefix from the original name, with the REMOVE_PREFIX macro.
This macro converts <originalName>, which is assumed to be in <originalFormat>, to <targetFormat>.
The supported formats are:
- Camel Case: New words start with a capital letter except for the first word, which begins with a lower case letter; for example, myVariableTable
- Pascal Case: Same as Camel Case but the first letter of the first word is upper case; for example, MyVariableTable
- Spaced: Words are separated by spaces; the case of letters is ignored
- Underscored: Words are separated by underscores; the case of letters is ignored.
Acronyms are not supported when converting from Camel Case or Pascal Case.
The original format might also specify a list of delimiters to be used. For example a value of ' _' breaks words whenever either a space or underscore is found.
The target format might also use a format string that specifies the case for each word and a delimiter between them. It takes the following form:
- <firstWord> controls the case of the first word (see below)
- <delimiter> is the string generated between words
- <otherWords> applies to all words after the first word.
<firstWord> and <otherWords> are both a sequence of two characters. The first character represents the case of the first letter of that word, and the second character represents the case of all subsequent letters. An upper case letter forces the output to upper case, a lower case letter forces the output to lower case, and any other character preserves the original case.
Example 1: To capitalize the first letter of each word and separate multiple words with a space:
"Ht( )Ht" to output "My Variable Table"
Example 2: To generate the equivalent of Camel Case, but reverse the roles of upper and lower case; that is, all characters are upper case except for the first character of each word after the first word:
"HT( )hT" to output "MY vARIABLE tABLE"
This macro removes any prefix found in <prefixes> from <originalName>. The prefixes are specified in a semi-colon separated list.
The macro is often used in conjunction with the CONVERT_NAME macro. For example, this code creates a get property name according to the options for Java.
$propertyName=%CONVERT_NAME($propertyName, "camel case", "pascal case")%