This document lists equivalences between Acceleo 2 and Acceleo 3 expressions.
Equilavence guide for miscellaneous expressions.
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/] |
<%import service.java%> | Services no longer need to be imported |
<%list + object%> | [list->including(object)/] |
<%object + list%> | [object->union(list)/] |
<%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 || list2%> | [list1->union(list2)/] |
<%list && object%> | [list->select(element | 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/] |
Equilavence guide for 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. |
Equilavence guide for 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")%> |
Equilavence guide for Resources services.
Acceleo 2 Expression | Acceleo 3 Expression (OCL) |
---|---|
<%getFileContent("C:/Obeo/models/MyModel.xmi")%> | |
<%getChainPath%> |
Equilavence guide for 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%> | [x.replaceAll('\r\n|\r|\n', '$0 ')/] |
<%x.indentTab%> | [x.replaceAll('\r\n|\r|\n', '$0t')/] |
Equilavence guide for System services.
Acceleo 2 Expression | Acceleo 3 Expression (OCL) |
---|---|
<%i()%> | [i/] |
<%args(0)%> | arguments are explicit and named in Acceleo 3 |
Equilavence guide for 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%> |
Equilavence guide for ENode services.
Acceleo 2 Expression | Acceleo 3 Expression (OCL) |
---|---|
<%eObject.adapt("EObject")%> | [eObject/] |
<%eObject.adapt("ENodeList")%> | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if] |
<%eObject.adapt("String")%> | [if (eObject.oclIsUndefined())][''/][else][eObject.toString()/][/if] |
<%eObject.adapt("Boolean")%> | [not eObject.oclIsUndefined()/] |
<%eObject.adapt("int")%> | [eObject->size()/] |
<%eObject.adapt("double")%> | [eObject->size().toString().toReal()/] |
<%eObject.adapt("List")%> | [if (eObject.oclIsUndefined())][Sequence{}/][else][Sequence{eObject}/][/if] |
<%eObject.adapt("ENode")%> | [eObject/] |
<%list.adapt("EObject")%> | [if (list.oclIsUndefined())][null/][elseif (list->size() == 0)][else][list.at(0)/][/if] |
<%list.adapt("ENodeList")%> | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if] |
<%list.adapt("String")%> | [if (list.oclIsUndefined())][''/][else][list.toString()/][/if] |
<%list.adapt("Boolean")% | [list->size() > 0/] |
<%list.adapt("int")%> | [list->size()/] |
<%list.adapt("double")%> | [list->size().toString().toReal()/] |
<%list.adapt("List")%> | [if (list.oclIsUndefined())][Sequence{}/][else][list/][/if] |
<%list.adapt("ENode")%> | [list/] |
<%string.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] |
<%string.adapt("String")%> | [string/] |
<%string.adapt("Boolean")%> | [string.equalsIgnoreCase('true')/] |
<%string.adapt("int")%> | [string.toInt()/] |
<%string.adapt("double")%> | [string.toReal()/] |
<%string.adapt("List")%> | [if (string.oclIsUndefined())][Sequence{}/][else][Sequence{string}/][/if] |
<%string.adapt("ENode")%> | [string/] |
<%boolean.adapt("EObject")%> | can only return empty enodes in Acceleo 2, so migration is simply "nothing" |
<%boolean.adapt("ENodeList")%> | [if (boolean.oclIsUndefined())][Sequence{}/][else][Sequence{boolean}/][/if] |
<%boolean.adapt("String")%> | [if (boolean.oclIsUndefined())][''/][else][boolean.toString()/][/if] |
<%boolean.adapt("Boolean")%> | [not boolean.oclIsUndefined() and boolean/] |
<%boolean.adapt("int")%> | [if (not boolean.oclIsUndefined() and boolean)][1/][else][0/][/if] |
<%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] |
<%boolean.adapt("ENode")%> | [boolean/] |
<%int.adapt("EObject")%> | can only return empty enodes in Acceleo 2, so migration is simply "nothing" |
<%int.adapt("ENodeList")%> | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if] |
<%int.adapt("String")%> | [if (int.oclIsUndefined())][''/][else][int.toString()/][/if] |
<%int.adapt("Boolean")%> | [not int.oclIsUndefined() and int > 0/] |
<%int.adapt("int")%> | [if (int.oclIsUndefined())][0/][else][int/][/if] |
<%int.adapt("double")%> | [if (int.oclIsUndefined())][0.0/][else][int.toString().toReal()/][/if] |
<%int.adapt("List")%> | [if (int.oclIsUndefined())][Sequence{}/][else][Sequence{int}/][/if] |
<%int.adapt("ENode")%> | [int/] |
<%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")%> |
Equilavence guide for Context services.
Acceleo 2 Expression | Acceleo 3 Expression (OCL) |
---|---|
<%get("key")%> | |
<%peek%> | |
<%pop%> | |
<%push%> | |
<%put("key", object) |
Equilavence guide for Properties services.
Acceleo 2 Expression | Acceleo 3 Expression (OCL) |
---|---|
<%getBestProperty("partial.key")%> | |
<%getProperty("key")%> | [getProperty('key')/] |
<%getProperty("propertiesFile", "key")%> | [getProperty('propertiesFile', 'key')/] |