Skip to main content
Jump to: navigation, search

M2T-JET/Whats New in 1.0 (Galileo)

Whats New in JET 1.0 (Galileo)

The following are the significant changes since the JET 0.9 (Ganymede) release. A complete list of enhancements and defect fixes for the release may be found here.

JET transformations now sensitive to Cancel

Executing JET transformations can now be canceled. Note that canceling may not terminate recursive loops.

Tag and template developers may check for cancellation by using TransformContextExtender.isCanceled() and may call TransformContextExtender.checkCanceled() to automatically abort if the transformation is canceled.

If a transformation is aborted, the JET2Platform runTransform() methods will return Status.CANCEL_STATUS.

See Bug 273913

Easily format generated Java code

A new tag <java:format> allows you to format its contents according to the Java formatting rules of the workspace or a specific project.

See Bug 262915

XPath function for accessing EMF EClass

A new XPath function, emf.eClass() will access the EClass of an object, if it has one. If object is an XPath variable referring to an EMF Object, then emf.eClass($object)/@name will return its EClass name.

If the argument is not specified, then it defaults to the current XPath context object.

See Bug 273331

XPath function for accessing UML2 Stereotypes

A new Xpath function, uml2.stereotype will access a stereotype on a UML2 Element, if it has one. If element is an XPath variable referring to a UML2 element, then uml2.stereotype($element, "Profile-name::Stereotype-name") will access the applied stereotype.

The first argument is optional. If not specified, it defaults to the current XPath context object.

See Bug 215339

The f:indent tag now preserves user regions

The f:indent tag now preserves user regions that it contains. In previous releases, information necessary to process these user regions was lost.

See Bug 272045

Improved integration with PDE build and international characters

PDE build assumes that all Java files have the same encoding (the default for the JVM executing the build). Prior to this release, JET would set the encoding a the Java class generated from each template to the same encoding as the template. This could be problematic if the selected encoding was not the one used by PDE build.

The JET compiler now compiles templates into Java classes that always have the default Java encoding. Characters that cannot be represented in that encoding are transformed into Unicode escape sequences.

In addition, a new JET template extension has been defined (.jet2) whose default encoding is UTF-8. The default encoding of files with a .jet use the platform's default encoding for text files - this can change from installation to installation.

See Bug 270985

Compact alternative to c:get tag

JET now permits the use of ${xpath-expression} within the static text as an alternative to the c:get tag. This expression form may also be used in tag attributes values as an alternative to {xpath-expression}.

For compatibility, existing JET projects will not support this unless the <transform> element in plugin.xml has the attribute enableEmbeddedExpressions="true". New JET projects are created with this attribute set.

When embedded expressions are enabled, you must escape the ${ if you want them to appear as static text in a template. Escaping is done by including the characters within a string literal inside an embedded expression.

For example, the template text

The value of ${'${$foo/@bar}'} is ${$foo/@bar}.

would expand to this text, if $foo/@bar evaluated to ABCDEF:

The value of ${$foo/@bar} is ABCDEF.

See Bug 179978

JET can now read .java files

If a JET transformation is given a .java file as input, then JET will create a JDT abstract syntax tree (AST) for the Java file, and allow templates to traverse this AST. The root element of the loaded document is typically compilationUnit.

The child steps available from any ast node are defined by the child and child list property descriptors available on the node.

The attributes available from any ast node are defined by the simple property descriptors available on the node. In addition, the following for attributes are always available:

  • offset - the 0-based offset of the node within the source
  • length - the length of the source text corresponding to the ast node
  • source - the source code corresponding to the ast node
  • nodeType - the simple class name (no package qualifier) of the AST node

An understanding of the JDT abstract syntax tree APIs is suggested.

As an example, the following XPath expression will return all fields declared in a class

/compilationUnit/types[@nodeType = 'TypeDeclaration']/bodyDeclarations[@nodeType = 'FieldDeclaration']

See the AST javadoc.

See Bug 268857

Generating content from recursive structures is now easier

JET now defines a tag c:deepIterate that allows for generation of text from a recursive structure.

For example, from a model such as:

<root description="Demo Model">
    <node name="a">
        <node name="c">
            <node name="d"/>
            <node name="e"/>
    <node name="b">
        <node name="f">
            <node name="g"/>
            <node name="h"/>
        <node name="i"/>

The following JET tag

<c:deepIterate select="node" initialContext="/root" indent="    ">
node ${@name}

would generate:

node a
    node c
        node d
        node e
node b
    node f
        node g
        node h
    node i

Child content may be position inside the parent content by using the c:deepContent tag within the c:deepIterate body.

The tag is also capable of doing breadth first traversals.

See Bug 268793

Back to the top