Intercalate is a foundation,
a framework, a future.
Intercalate is based on principle, designed to embrace, built to sustain. |
|
As for the previous examples of mail-merging, Intercalate generates textual realizations of a model by looking up and replacing keywords in a Template with values found in a Property List. These realizations are not restricted to a single output file or passive text substitutions. For example, suppose we wished to be able to access with Java classes personal and vehicle data stored in a relational database. The final structure of the database schema has not quite settled down yet, but we have to proceed with the project. We want a means to automatically generate the source code for our Java classes whenever the schema is changed so that the coupling remains correct and current.
The Property List shown below contains a representation of people and their vehicles, as derived from a database schema having tables and columns. A person has a name and identifying number, each with its data type and size. A vehicle is similarly characterized by a vehicle ID, make, and the identifier of its owner.
|
A Property List may also contain tables which represent regular conversions of values from one domain to another. In this example, the sql2java lookup table is used to convert the database SQL data types into corresponding Java data types.
More advanced Property Lists may additionally contain keys representing default values and relationships between objects in the model.
The values in a Property List are most often text to be substituted into a template, but may also themselves be templates which reference other keys, to any desired degree of nesting. The javatype key is an example of this.
An Intercalate Template describes how the model, represented by the Property List, should be converted to a textual realization. A Template is composed of text interleaved with keywords. Text is copied to the output verbatim, while keywords direct Intercalate to look up values in the Property List or perform other processing actions. The keywords and control directives are delimited by dollar signs, and, in addition to value substitution, support conditional processing, repeated processing, input and output control, and case adjustments to values.
|
The Template shown here, when applied to the model above, generates a Java class for each of the tables listed, with instance variables and accessor methods for the columns. Of course a complete Java class that includes business logic and a persistence mechanism would contain many more methods and is beyond the scope of this example.
Not shown here is a second template, one that generates the SQL that creates the tables that correspond to the structure specified in the property list.
Below are the Java classes generated by processing the model through the Template. Some white space has been removed to condense the display.
|
|
So now suppose that it is decided that the database schema is going to
change. What happens then? Look at the next page to find out.
< Back 1 2 3 4 5 6 7 8 9 Next > |
Copyright © 2003 Alodar Systems, Inc. All rights reserved.