Java Reference
In-Depth Information
To match all templates with at least one String parameter:
« AROUND *(String s,*) FOR Object»
You can call the underlying definition using proceed() on the implicit vari-
able targetDef . The original parameters are passed to the underlying defini-
tion, but you can modify this with the advice beforehand. You can achieve total
control over the parameters passed using proceed(Object target, List
params) , although no type checking occurs when you do so.
Let's take a look at a simple example of using «AROUND» . Consider this por-
tion of a previous version of the mindmap2csv file template:
« DEFINE Main FOR Map»
« FILE title + "-topics.csv"-»
« EXPAND listElements FOR elements.typeSelect(Topic)»
« ENDFILE »
« ENDDEFINE »
« DEFINE listElements FOR List[mindmap::Topic]-»
« FOREACH this AS topic-»
« EXPAND csv FOR topic-»
« ENDFOREACH »
« ENDDEFINE »
« DEFINE csv FOR Topic-»
«name»,«start»,«end»
« ENDDEFINE »
Here, the Topic elements are expanded into CSV line entries where their
name, start date, and end date values are written. Let's assume that it's legal to
enter a comment at the top of a CSV file to describe each entry, preceded by a #
sign. If we weren't given access to the template, or if we did not want to modify
it, we could use «AROUND» to noninvasively add a comment line before each
Topic line in our output. This is a new .xpt file with an «AROUND» statement
that lets us do just that:
« IMPORT mindmap»
« AROUND templates::mindmap2csv::listElements FOR List[mindmap::Topic]-»
# Topic Name, Start Date, End Date
«targetDef.proceed()»
« ENDAROUND »
Using the qualified name of the «DEFINE» that we want to augment instructs
the generator that this block will be executed in its stead, stating that it should
output a simple comment line and then proceed with the original statement using
Search WWH ::




Custom Search