Date: Fri, 29 Mar 2024 15:24:44 +0100 (CET) Message-ID: <1114973941.2180.1711722284943@nm-docs> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2179_896526208.1711722284943" ------=_Part_2179_896526208.1711722284943 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Instead of explicitly creating an AlfCompiler object and using = its methods, you can alternatively parse and map Alf code using static meth= ods provided by the AlfActionUtil class.
The AlfActionUtil.parse method takes a Named Element and, using= this as the context element, parses and constraint checks the Alf body of = the Element, if it has one. If the parsing and constraint checking succeed,= then the method also automatically registers dependencies. The method retu= rns a Boolean indicating whether the parse succeeded or not. If the parse f= ails, Compiler Errors are reported in an error message that is attached to = the context element using an error Annotation (which then becomes available= as an Active Validation Result, as described in the Alf edit= or).
if (AlfA= ctionUtil.parse(element)) { =09// Parse was successful. =09... }
The AlfActionUtil.compile method t= akes a Named Element and, using this as the context element, both parses an= d maps the Alf body of the Element, if it has one. If the compilation is su= ccessful, then the method updates the context element and automatically reg= isters dependencies. The method returns a Boolean indicating whether t= he parse succeeded or not. As with the parse method, if the compil= ation fails, Compiler Errors are recorded in an error message that is attac= hed to the context element using an error Annotation. Unlike the AlfCom= piler.map and AlfCompiler.compile methods, you do not need to= explicitly start a MagicDraw session to call the AlfActionUtil.compile= method, because it ensures internally that a session is started for m= apping, if necessary.
if (AlfA= ctionUtil.compile(element)) { =09// Compilation was successful. =09... }