Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Acceleo/Migration From Acceleo 2"

m (Acceleo 2.x to 3.x equivalences)
m (Formatting)
Line 145: Line 145:
 
=== String Services ===
 
=== String Services ===
  
 
+
{| border="1" cellpadding="5" cellspacing="0"
 
+
|-
 
+
! style="background: #BCBCBC;" align="center"| Acceleo 2 Expression
  | Acceleo 2 Expression                                           | Acceleo 3 Expression (OCL)                                     |
+
! style="background: #BCBCBC;" align="center"| Acceleo 3 Expression (OCL)
  +================================================================+================================================================+
+
|-
  | <%x.length%>                                                   | [x.size()/]                                                   |
+
| <%x.length%>
 
+
| [x.size()/]
  | <%x.toUpperCase%>                                             | [x.toUpper()/]                                                 |
+
|-
 
+
| <%x.toUpperCase%>
  | <%x.toLowerCase%>                                             | [x.toLower()/]                                                 |
+
| [x.toUpper()/]
 
+
|-
  | <%x.toU1Case%>                                                 | [x.toUpperFirst()/]                                           |
+
| <%x.toLowerCase%>
 
+
| [x.toLower()/]
  | <%x.toL1Case%>                                                 | [x.toLowerFirst()/]                                           |
+
|-
 
+
| <%x.toU1Case%>
  | <%x.substring(1, 3)%>                                         | [x.substring(2, 3)/]                                           |
+
| [x.toUpperFirst()/]
 
+
|-
  | <%x.substring(1)%>                                             | [x.substring(2)/]                                             |
+
| <%x.toL1Case%>
 
+
| [x.toLowerFirst()/]
  | <%x.replaceAll("test", "replaced")%>                           | [x.replaceAll('test', 'replaced')/]                           |
+
|-
 
+
| <%x.substring(1, 3)%>
  | <%x.replaceAll("\w", "$0")%>                                   | [x.replaceAll('\\w', '$0')/]                                   |
+
| [x.substring(2, 3)/]
 
+
|-
  | <%x.replaceFirst("test", "replaced")%>                         | [x.replace('test', 'replaced')/]                               |
+
| <%x.substring(1)%>
 
+
| [x.substring(2)/]
  | <%x.replaceFirst("\w", "$0")%>                                 | [x.replace('\\w', '$0')/]                                     |
+
|-
 
+
| <%x.replaceAll("test", "replaced")%>
  | <%x.trim%>                                                     | [x.trim()/]                                                   |
+
| [x.replaceAll('test', 'replaced')/]
 
+
|-
  | <%x.startsWith(y)%>                                           | [x.startsWith(y)/]                                             |
+
| <%x.replaceAll("\w", "$0")%>
 
+
| [x.replaceAll('\\w', '$0')/]
  | <%x.endsWith(y)%>                                             | [x.endsWith(y)/]                                               |
+
|-
 
+
| <%x.replaceFirst("test", "replaced")%>
  | <%x.equalsIgnoreCase(y)%>                                     | [x.equalsIgnoreCase(y)/]                                       |
+
| [x.replace('test', 'replaced')/]
 
+
|-
  | <%x.matches(y)%>                                               | [x.matches(y)/]                                               |
+
| <%x.replaceFirst("\w", "$0")%>
 
+
| [x.replace('\\w', '$0')/]
  | <%x.charAt(4)%>                                               | [x.substring(5, 5)/]                                           |
+
|-
 
+
| <%x.trim%>
  | <%x.indexOf(y)%>                                               | [x.index(y)/]                                                 |
+
| [x.trim()/]
 
+
|-
  | <%x.indexOf(y, 4)%>                                           | [x.substring(5, x.size()).index(y) + 4/]                       |
+
| <%x.startsWith(y)%>
 
+
| [x.startsWith(y)/]
  | <%x.lastIndexOf(y)%>                                           | [x.lastIndex(y)/]                                             |
+
|-
 
+
| <%x.endsWith(y)%>
  | <%x.lastIndexOf(y, 4)%>                                       | [x.substring(5, x.size()).lastIndex(y) + 4/]                   |
+
| [x.endsWith(y)/]
 
+
|-
  | <%x.split(y)%>                                                 | No direct equivalent, use String::tokenize(String)             |
+
| <%x.equalsIgnoreCase(y)%>
 
+
| [x.equalsIgnoreCase(y)/]
  | <%x.indentSpace%>                                             | [x.replaceAll('\r\n|\r|\n', '$0 ')/]                           |
+
|-
 
+
| <%x.matches(y)%>
  | <%x.indentTab%>                                               | [x.replaceAll('\r\n|\r|\n', '$0\t')/]                         |
+
| [x.matches(y)/]
 +
|-
 +
| <%x.charAt(4)%>
 +
| [x.substring(5, 5)/]
 +
|-
 +
| <%x.indexOf(y)%>
 +
| [x.index(y)/]
 +
|-
 +
| <%x.indexOf(y, 4)%>
 +
| [x.substring(5, x.size()).index(y) + 4/]
 +
|-
 +
| <%x.lastIndexOf(y)%>
 +
| [x.lastIndex(y)/]
 +
|-
 +
| <%x.lastIndexOf(y, 4)%>
 +
| [x.substring(5, x.size()).lastIndex(y) + 4/]
 +
|-
 +
| <%x.split(y)%>
 +
| No direct equivalent, use String::tokenize(String)
 +
|-
 +
| <%x.indentSpace%>
 +
| [x.replaceAll('\r\n|\r|\n', '$0 ')/]
 +
|-
 +
| <%x.indentTab%>
 +
| [x.replaceAll('\r\n|\r|\n', '$0\t')/]
 +
|}
  
 
      
 
      
Line 253: Line 278:
 
=== ENode Services ===
 
=== ENode Services ===
  
 
+
{| border="1" cellpadding="5" cellspacing="0"
 
+
|-
  | Acceleo 2 Expression                                           | Acceleo 3 Expression (OCL)                                                               |
+
! style="background: #BCBCBC;" align="center"| Acceleo 2 Expression
  +==========+
+
! style="background: #BCBCBC;" align="center"| Acceleo 3 Expression (OCL)
  | <%eObject.adapt("EObject")%>                                  | [eObject/]                                                                                |
+
|-
 
+
| <%eObject.adapt("EObject")%>                                  | [eObject/]                                                                                |
  | <%eObject.adapt("ENodeList")%>                                | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if]              |
+
| <%eObject.adapt("ENodeList")%>                                | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if]              |
 
+
| <%eObject.adapt("String")%>                                    | [if (eObject.oclIsUndefined())][''/][else][eObject.toString()/][/if]                      |
  | <%eObject.adapt("String")%>                                    | [if (eObject.oclIsUndefined())][''/][else][eObject.toString()/][/if]                      |
+
| <%eObject.adapt("Boolean")%>                                  | [not eObject.oclIsUndefined()/]                                                          |
 
+
| <%eObject.adapt("int")%>                                      | [eObject->size()/]                                                                        |
  | <%eObject.adapt("Boolean")%>                                  | [not eObject.oclIsUndefined()/]                                                          |
+
| <%eObject.adapt("double")%>                                    | [eObject->size().toString().toReal()/]                                                    |
 
+
| <%eObject.adapt("List")%>                                      | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if]              |
  | <%eObject.adapt("int")%>                                      | [eObject->size()/]                                                                        |
+
| <%eObject.adapt("ENode")%>                                    | [eObject/]                                                                                |
 
+
| <%list.adapt("EObject")%>                                      | [if (list.oclIsUndefined())][null/][elseif (list->size() == 0)][else][list.at(0)/][/if]  |
  | <%eObject.adapt("double")%>                                    | [eObject->size().toString().toReal()/]                                                    |
+
| <%list.adapt("ENodeList")%>                                    | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if]                              |
 
+
| <%list.adapt("String")%>                                      | [if (list.oclIsUndefined())][''/][else][list.toString()/][/if]                            |
  | <%eObject.adapt("List")%>                                      | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if]              |
+
| <%list.adapt("Boolean")%                                      | [list->size() > 0/]                                                                      |
 
+
| <%list.adapt("int")%>                                          | [list->size()/]                                                                          |
  | <%eObject.adapt("ENode")%>                                    | [eObject/]                                                                                |
+
| <%list.adapt("double")%>                                      | [list->size().toString().toReal()/]                                                      |
 
+
| <%list.adapt("List")%>                                        | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if]                              |
  | <%list.adapt("EObject")%>                                      | [if (list.oclIsUndefined())][null/][elseif (list->size() == 0)][else][list.at(0)/][/if]  |
+
| <%list.adapt("ENode")%>                                        | [list/]                                                                                  |
 
+
| <%string.adapt("EObject")%>                                    | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
  | <%list.adapt("ENodeList")%>                                    | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if]                              |
+
| <%string.adapt("ENodeList")%>                                  | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if]                |
 
+
| <%string.adapt("String")%>                                    | [string/]                                                                                |
  | <%list.adapt("String")%>                                      | [if (list.oclIsUndefined())][''/][else][list.toString()/][/if]                            |
+
| <%string.adapt("Boolean")%>                                    | [string.equalsIgnoreCase('true')/]                                                        |
 
+
| <%string.adapt("int")%>                                        | [string.toInt()/]                                                                        |
  | <%list.adapt("Boolean")%                                      | [list->size() > 0/]                                                                      |
+
| <%string.adapt("double")%>                                    | [string.toReal()/]                                                                        |
 
+
| <%string.adapt("List")%>                                      | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if]                |
  | <%list.adapt("int")%>                                          | [list->size()/]                                                                          |
+
| <%string.adapt("ENode")%>                                      | [string/]                                                                                |
 
+
| <%boolean.adapt("EObject")%>                                  | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
  | <%list.adapt("double")%>                                      | [list->size().toString().toReal()/]                                                      |
+
| <%boolean.adapt("ENodeList")%>                                | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if]              |
 
+
| <%boolean.adapt("String")%>                                    | [if (boolean.oclIsUndefined())][''/][else][boolean.toString()/][/if]                      |
  | <%list.adapt("List")%>                                        | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if]                              |
+
| <%boolean.adapt("Boolean")%>                                  | [not boolean.oclIsUndefined() and boolean/]                                              |
 
+
| <%boolean.adapt("int")%>                                      | [if (not boolean.oclIsUndefined() and boolean)][1/][else][0/][/if]                        |
  | <%list.adapt("ENode")%>                                        | [list/]                                                                                  |
+
| <%boolean.adapt("double")%>                                    | [if (not boolean.oclIsUndefined() and boolean)][1.0/][else][0.0/][/if]                    |
 
+
| <%boolean.adapt("List")%>                                      | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if]              |
  | <%string.adapt("EObject")%>                                    | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
+
| <%boolean.adapt("ENode")%>                                    | [boolean/]                                                                                |
 
+
| <%int.adapt("EObject")%>                                      | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
  | <%string.adapt("ENodeList")%>                                  | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if]                |
+
| <%int.adapt("ENodeList")%>                                    | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if]                      |
 
+
| <%int.adapt("String")%>                                        | [if (int.oclIsUndefined())][''/][else][int.toString()/][/if]                              |
  | <%string.adapt("String")%>                                    | [string/]                                                                                |
+
| <%int.adapt("Boolean")%>                                      | [not int.oclIsUndefined() and int > 0/]                                                  |
 
+
| <%int.adapt("int")%>                                          | [if (int.oclIsUndefined())][0/][else][int/][/if]                                          |
  | <%string.adapt("Boolean")%>                                    | [string.equalsIgnoreCase('true')/]                                                        |
+
| <%int.adapt("double")%>                                        | [if (int.oclIsUndefined())][0.0/][else][int.toString().toReal()/][/if]                    |
 
+
| <%int.adapt("List")%>                                          | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if]                      |
  | <%string.adapt("int")%>                                        | [string.toInt()/]                                                                        |
+
| <%int.adapt("ENode")%>                                        | [int/]                                                                                    |
 
+
| <%double.adapt("EObject")%>                                    | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
  | <%string.adapt("double")%>                                    | [string.toReal()/]                                                                        |
+
| <%double.adapt("ENodeList")%>                                  | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if]                |
 
+
| <%double.adapt("String")%>                                    | [if (double.oclIsUndefined())][''/][else][double.toString()/][/if]                        |
  | <%string.adapt("List")%>                                      | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if]                |
+
| <%double.adapt("Boolean")%>                                    | [not double.oclIsUndefined() and double > 0/]                                            |
 
+
| <%double.adapt("int")%>                                        | [if (double.oclIsUndefined())][0/][else][double.toString().toInt()/][/if]                |
  | <%string.adapt("ENode")%>                                      | [string/]                                                                                |
+
| <%double.adapt("double")%>                                    | [if (double.oclIsUndefined())][0.0/][else][double/][/if]                                  |
 
+
| <%double.adapt("List")%>                                      | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if]                |
  | <%boolean.adapt("EObject")%>                                  | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
+
| <%double.adapt("ENode")%>                                      | [double/]                                                                                |
 
+
| <%list.cast("EClass")%>                                        | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/]                          |
  | <%boolean.adapt("ENodeList")%>                                | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if]              |
+
| <%list.filter("EClass")%>                                      | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/]                          |
 
+
| <%current()%>                                                  | [self/]                                                                                  |
  | <%boolean.adapt("String")%>                                    | [if (boolean.oclIsUndefined())][''/][else][boolean.toString()/][/if]                      |
+
| <%current(1)%>                                                | iterator variables are named in Acceleo 3                                                |
 
+
| <%node.debug%>                                                |                                                                                          |
  | <%boolean.adapt("Boolean")%>                                  | [not boolean.oclIsUndefined() and boolean/]                                              |
+
| <%node.trace%>                                                |                                                                                          |
 
+
| <%node.trace("name")%>                                        |                                                                                          |
  | <%boolean.adapt("int")%>                                      | [if (not boolean.oclIsUndefined() and boolean)][1/][else][0/][/if]                        |
+
| <%nPut("key", object)%>                                        |                                                                                          |
 
+
| <%nGet("key")%>                                                |                                                                                          |
  | <%boolean.adapt("double")%>                                    | [if (not boolean.oclIsUndefined() and boolean)][1.0/][else][0.0/][/if]                    |
+
| <%nPeek%>                                                      |                                                                                          |
 
+
| <%nPop%>                                                      |                                                                                          |
  | <%boolean.adapt("List")%>                                      | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if]              |
+
| <%nPush%>                                                      |                                                                                          |
 
+
| <%list.nMinimize%>                                            | [list->asOrderedSet()->asSequence()/]                                                    |
  | <%boolean.adapt("ENode")%>                                    | [boolean/]                                                                                |
+
| <%list.minimize%>                                              | [list->asOrderedSet()->asSequence()/]                                                    |
 
+
| <%list.nContains(item)%>                                      | [list->includes(item)/]                                                                  |
  | <%int.adapt("EObject")%>                                      | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
+
| <%list.nFirst%>                                                | [list->first()/]                                                                          |
 
+
| <%list.nLast%>                                                | [list->last()/]                                                                          |
  | <%int.adapt("ENodeList")%>                                    | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if]                      |
+
| <%list.nGet(0)%>                                              | [list->at(0)/]                                                                            |
 
+
| <%list.nGet(0, 1)%>                                            | [list->subSequence(1, 2)/]                                                                |
  | <%int.adapt("String")%>                                        | [if (int.oclIsUndefined())][''/][else][int.toString()/][/if]                              |
+
| <%list.nReverse%>                                              | [list->reverse()/]                                                                        |
 
+
| <%list.reverse%>                                              | [list->reverse()/]                                                                        |
  | <%int.adapt("Boolean")%>                                      | [not int.oclIsUndefined() and int > 0/]                                                  |
+
| <%list.nSize%>                                                | [list->size()/]                                                                          |
 
+
| <%list.nSort%>                                                | [list->sortedBy(toString())/]                                                            |
  | <%int.adapt("int")%>                                          | [if (int.oclIsUndefined())][0/][else][int/][/if]                                          |
+
| <%list.nSort(name)%>                                          | [list->sortedBy(name)/]                                                                  |
 
+
| <%list.sort%>                                                  | [list->sortedBy(toString())->asOrderedSet()->asSequence()/]                              |
  | <%int.adapt("double")%>                                        | [if (int.oclIsUndefined())][0.0/][else][int.toString().toReal()/][/if]                    |
+
| <%list.sort(name)%>                                            | [list->sortedBy(name)->asOrderedSet()->asSequence()/]                                    |
 
+
| <%list.sep(",")%>                                              | [list->sep(',')/]                                                                        |
  | <%int.adapt("List")%>                                          | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if]                      |
+
| <%list.sepStr(",")%>                                          | [list->sep(',')/]                                                                        |
 
+
| <%node.toString%>                                              | [node.toString()/]                                                                        |
  | <%int.adapt("ENode")%>                                        | [int/]                                                                                    |
+
| <%eObject.until("eContainer", "EClass")%>                      |                                                                                          |
 
+
  | <%double.adapt("EObject")%>                                    | can only return empty enodes in Acceleo 2, so migration is simply "nothing"              |
+
 
+
  | <%double.adapt("ENodeList")%>                                  | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if]                |
+
 
+
  | <%double.adapt("String")%>                                    | [if (double.oclIsUndefined())][''/][else][double.toString()/][/if]                        |
+
 
+
  | <%double.adapt("Boolean")%>                                    | [not double.oclIsUndefined() and double > 0/]                                            |
+
 
+
  | <%double.adapt("int")%>                                        | [if (double.oclIsUndefined())][0/][else][double.toString().toInt()/][/if]                |
+
 
+
  | <%double.adapt("double")%>                                    | [if (double.oclIsUndefined())][0.0/][else][double/][/if]                                  |
+
 
+
  | <%double.adapt("List")%>                                      | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if]                |
+
 
+
  | <%double.adapt("ENode")%>                                      | [double/]                                                                                |
+
 
+
  | <%list.cast("EClass")%>                                        | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/]                          |
+
 
+
  | <%list.filter("EClass")%>                                      | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/]                          |
+
 
+
  | <%current()%>                                                  | [self/]                                                                                  |
+
 
+
  | <%current(1)%>                                                | iterator variables are named in Acceleo 3                                                |
+
 
+
  | <%node.debug%>                                                |                                                                                          |
+
 
+
  | <%node.trace%>                                                |                                                                                          |
+
 
+
  | <%node.trace("name")%>                                        |                                                                                          |
+
 
+
  | <%nPut("key", object)%>                                        |                                                                                          |
+
 
+
  | <%nGet("key")%>                                                |                                                                                          |
+
 
+
  | <%nPeek%>                                                      |                                                                                          |
+
 
+
  | <%nPop%>                                                      |                                                                                          |
+
 
+
  | <%nPush%>                                                      |                                                                                          |
+
 
+
  | <%list.nMinimize%>                                            | [list->asOrderedSet()->asSequence()/]                                                    |
+
 
+
  | <%list.minimize%>                                              | [list->asOrderedSet()->asSequence()/]                                                    |
+
 
+
  | <%list.nContains(item)%>                                      | [list->includes(item)/]                                                                  |
+
 
+
  | <%list.nFirst%>                                                | [list->first()/]                                                                          |
+
 
+
  | <%list.nLast%>                                                | [list->last()/]                                                                          |
+
 
+
  | <%list.nGet(0)%>                                              | [list->at(0)/]                                                                            |
+
 
+
  | <%list.nGet(0, 1)%>                                            | [list->subSequence(1, 2)/]                                                                |
+
 
+
  | <%list.nReverse%>                                              | [list->reverse()/]                                                                        |
+
 
+
  | <%list.reverse%>                                              | [list->reverse()/]                                                                        |
+
 
+
  | <%list.nSize%>                                                | [list->size()/]                                                                          |
+
 
+
  | <%list.nSort%>                                                | [list->sortedBy(toString())/]                                                            |
+
 
+
  | <%list.nSort(name)%>                                          | [list->sortedBy(name)/]                                                                  |
+
 
+
  | <%list.sort%>                                                  | [list->sortedBy(toString())->asOrderedSet()->asSequence()/]                              |
+
 
+
  | <%list.sort(name)%>                                            | [list->sortedBy(name)->asOrderedSet()->asSequence()/]                                    |
+
 
+
  | <%list.sep(",")%>                                              | [list->sep(',')/]                                                                        |
+
 
+
  | <%list.sepStr(",")%>                                          | [list->sep(',')/]                                                                        |
+
 
+
  | <%node.toString%>                                              | [node.toString()/]                                                                        |
+
 
+
  | <%eObject.until("eContainer", "EClass")%>                      |                                                                                          |
+
  
 
    
 
    

Revision as of 04:07, 20 January 2011

Migration Guide

Acceleo 2.x to 3.x equivalences

Miscellaneous

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%metamodel http://www.eclipse.org/uml2/2.0.0/UML%> [module module_name('http://www.eclipse.org/uml2/2.0.0/UML')/]
<%import module.mt%> [import module/] or [import org::eclipse::acceleo::mypackage::module/]
<%import service.java%> Services no longer need to be imported
<%list + object%> [list->including(object)/]
<%list1 + list2%> [list1->union(list2)/]
<%string + object%> [string + object/]
<%list - object%> [list->excluding(object)/]
<%list1 - list2%> [list1->asSet() - list2->asSet()/] (Note that this no longer keeps duplicates, which is not strictly equivalent to Acceleo 2)
<%list1 \p\p list2%> [list1->union(list2)/]
<%list && object%> element = object)/]
<%list1 && list2%> [list1->iterate(element; result : Sequence(T) = Sequence{} if list2->includes(element) then result->including(element) else result endif)/]
<%list1 == list2%> [list1 = list2/]
<%list1 != list2%> [list1 <> list2/]
<%object != object%> [object <> object/]
<%! boolean%> [not boolean/]

EObject Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%x.eAllContents%> [x.eAllContents()/]
<%x.eAllContents("EClass")%> [x.eAllContents(EClass)/]
<%x.eClass%> [x.eClass()/]
<%x.eContainer%> [x.eContainer()/]
<%x.eContainer("EPackage")%> [x.eContainer(EPackage)/]
<%x.eContainingFeature%> [x.eContainingFeature()/]
<%x.eContainmentFeature%> [x.eContainmnentFeature()/]
<%x.eContents%> [x.eContents()/]
<%x.eCrossReferences%> [x.eCrossReferences()/]
<%x.eResource%> [x.eResource()/]
<%x.eResourceName%>
<%x.getRootContainer%> [x.ancestors()->last()/]
<%load("//UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2")%> No direct equivalent : Acceleo 3 accepts more than one model element as arguments of a generation. An alternative would be to use a custom Java service for this need.


Request Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%list.select("eAttributes.nSize() > 0")%> [list->select(eAttributes->size() > 0)/]
<%list.select("eAttributes.nSize()", "0")%> [list->select(eAttributes->size() = 0)/]
<%list.delete("eAttributes.nSize() > 0")%> [list->reject(eAttributes->size() > 0)/]
<%list.delete("eAttributes.nSize()", "0")%> [list->reject(eAttributes->size() = 0)/]
<%evaluate("2 + 4")%>


Resource Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%getFileContent("C:/Obeo/models/MyModel.xmi")%>
<%getChainPath%>


String Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%x.length%> [x.size()/]
<%x.toUpperCase%> [x.toUpper()/]
<%x.toLowerCase%> [x.toLower()/]
<%x.toU1Case%> [x.toUpperFirst()/]
<%x.toL1Case%> [x.toLowerFirst()/]
<%x.substring(1, 3)%> [x.substring(2, 3)/]
<%x.substring(1)%> [x.substring(2)/]
<%x.replaceAll("test", "replaced")%> [x.replaceAll('test', 'replaced')/]
<%x.replaceAll("\w", "$0")%> [x.replaceAll('\\w', '$0')/]
<%x.replaceFirst("test", "replaced")%> [x.replace('test', 'replaced')/]
<%x.replaceFirst("\w", "$0")%> [x.replace('\\w', '$0')/]
<%x.trim%> [x.trim()/]
<%x.startsWith(y)%> [x.startsWith(y)/]
<%x.endsWith(y)%> [x.endsWith(y)/]
<%x.equalsIgnoreCase(y)%> [x.equalsIgnoreCase(y)/]
<%x.matches(y)%> [x.matches(y)/]
<%x.charAt(4)%> [x.substring(5, 5)/]
<%x.indexOf(y)%> [x.index(y)/]
<%x.indexOf(y, 4)%> [x.substring(5, x.size()).index(y) + 4/]
<%x.lastIndexOf(y)%> [x.lastIndex(y)/]
<%x.lastIndexOf(y, 4)%> [x.substring(5, x.size()).lastIndex(y) + 4/]
<%x.split(y)%> No direct equivalent, use String::tokenize(String)
<%x.indentSpace%> \r|\n', '$0 ')/]
<%x.indentTab%> \r|\n', '$0\t')/]


System Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%i()%> [i/]
<%args(0)%> arguments are explicit and named in Acceleo 3


XPath Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%x.ancestor%> [x.ancestors()/]
<%x.parent%> [x.eContainer()/]
<%self%> [self/]
<%x.child%> [x.eContents()/]
<%x.descendant%> [x.eAllContents()/]
<%x.precedingSibling%> [x.precedingSiblings()/]
<%x.preceding%>
<%x.followingSibling%> [x.followingSiblings()/]
<%x.following%>


ENode Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
[eObject/] | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if] | [if (eObject.oclIsUndefined())][/][else][eObject.toString()/][/if] | [not eObject.oclIsUndefined()/] | [eObject->size()/] | [eObject->size().toString().toReal()/] | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if] | [eObject/] | [if (list.oclIsUndefined())][null/][elseif (list->size() == 0)][else][list.at(0)/][/if] | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if] | [if (list.oclIsUndefined())][/][else][list.toString()/][/if] | [list->size() > 0/] | [list->size()/] | [list->size().toString().toReal()/] | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if] | [list/] | can only return empty enodes in Acceleo 2, so migration is simply "nothing" | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if] | [string/] | [string.equalsIgnoreCase('true')/] | [string.toInt()/] | [string.toReal()/] | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if] | [string/] | can only return empty enodes in Acceleo 2, so migration is simply "nothing" | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if] | [if (boolean.oclIsUndefined())][/][else][boolean.toString()/][/if] | [not boolean.oclIsUndefined() and boolean/] | [if (not boolean.oclIsUndefined() and boolean)][1/][else][0/][/if] | [if (not boolean.oclIsUndefined() and boolean)][1.0/][else][0.0/][/if] | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if] | [boolean/] | can only return empty enodes in Acceleo 2, so migration is simply "nothing" | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if] | [if (int.oclIsUndefined())][/][else][int.toString()/][/if] | [not int.oclIsUndefined() and int > 0/] | [if (int.oclIsUndefined())][0/][else][int/][/if] | [if (int.oclIsUndefined())][0.0/][else][int.toString().toReal()/][/if] | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if] | [int/] | can only return empty enodes in Acceleo 2, so migration is simply "nothing" | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if] | [if (double.oclIsUndefined())][/][else][double.toString()/][/if] | [not double.oclIsUndefined() and double > 0/] | [if (double.oclIsUndefined())][0/][else][double.toString().toInt()/][/if] | [if (double.oclIsUndefined())][0.0/][else][double/][/if] | [if (double.oclIsUndefined())][Sequence{}/][else][Sequence{double}/][/if] | [double/] | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/] | [list->select(not oclIsKindOf(EObject) or oclIsKindOf(EClass))/] | [self/] | iterator variables are named in Acceleo 3 | | | | | | | | | [list->asOrderedSet()->asSequence()/] | [list->asOrderedSet()->asSequence()/] | [list->includes(item)/] | [list->first()/] | [list->last()/] | [list->at(0)/] | [list->subSequence(1, 2)/] | [list->reverse()/] | [list->reverse()/] | [list->size()/] | [list->sortedBy(toString())/] | [list->sortedBy(name)/] | [list->sortedBy(toString())->asOrderedSet()->asSequence()/] | [list->sortedBy(name)->asOrderedSet()->asSequence()/] | [list->sep(',')/] | [list->sep(',')/] | [node.toString()/] | |


Context Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%get("key")%>
<%peek%>
<%pop%>
<%push%>
<%put("key", object)%>


Properties Services

Acceleo 2 Expression Acceleo 3 Expression (OCL)
<%getBestProperty("partial.key")%>
<%getProperty("key")%> [getProperty('key')/]
<%getProperty("propertiesFile", "key")%> [getProperty('propertiesFile', 'key')/]



Acceleo Portal
Project Project · Installation
Features Acceleo Features · Runtime · Acceleo editor · Views & Perspective · Interpreter · Maven
User documentation Getting Started · User Guide · Acceleo operations reference · OCL operations reference · Text Production Rules · Migration From Acceleo 2.x · Best Practices · Videos · FAQ
Developer documentation Source code · How to contribute · Compatibility · MOFM2T specification · OCL specification
Community Professional Support · Report a bug

Back to the top