DOC PREVIEW
Columbia COMS W4115 - JTemplate

This preview shows page 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-111-112-113-114-115-116-117-118-119-120-121-122-123-124-125-126-223-224-225-226-227-228-229-230-231-232-233-234-235-236-237-238 out of 238 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 238 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Jtemplate white paperIntroduction to JtemplateLanguage Reference ManualIntroductionLexical ConventionExpressionsStatementsScopeObject Oriented ConstructsBuilt in LibraryDevelopment Process & Architectural GuideDevelopment ProcessLanguage DesignProject ScheduleDevelopment ToolsTestingArchitectural GuidePerformanceLessons LearnedSuggestions for future project teamsModule documentationSource codeTestsBenchmarksAbed Tony [email protected] W4115 Final ReportProfessor Stephen EdwardsSummer 2009Abed Tony BenBrahim [email protected] JTemplate: Another Approach to Document Template Markup Languages1 Introduction In domains such as web page development and model driven software development (MDSD), the automated generation of documents is most often accomplished by the use of processing instructions written in a markup language, embedded directly into a document template, to conditionally or iteratively generate sections of the document or programmatically insert content. Mainstream web development technologies such as Java Server Pages, PHP, Ruby on Rails and Microsoft’s ASP(X) all employ this method of embedding code inside a document template to generate dynamic content. In the same fashion, popular MDSD frameworks such as openArchitectureWare (openArchitectureWare 2009) make extensive use of templates to transform application models to source code. The use of templates with embedded processing instructions greatly accelerates the initial development of document generation applications. However this methodology imposes severe penalties in terms of future maintainability. As the ratio of markup instructions to template content increases (Figure 1), it becomes increasingly difficult to locate and correct defects. Often, the template becomes a “write once” document, with each modification becoming prohibitively more expensive and error-prone to undertake. Figure 1- A view of an openArchitectureWare template to generate an Oracle PL/SQL package Several approaches have emerged to achieve the holy grail of separating markup instructions from content. The Apache Wicket web framework (Apache Wicket 2009) takes advantage of the tree structure of HTML to insert content into specified nodes, an approach that works well for2 XML like and other hierarchical structures but presents severe challenges for less structured content such as a source code. Terrence Parr’s StringTemplate library (Parr 2004) makes use of minimal template markup and an output grammar to generate dynamic content. While this is a promising approach, the use of output grammars and complex recursive constructs has hindered the widespread adoption of this technique. The JTemplate language proposed in this document explores another method of providing clear separation of markup instructions from content. The JTemplate Language Defining Templates In the JTemplate language, templates are first-class constructs. The following code snippet shows a template for a Java bean, with each line of the template annotated with an optional label (an integer or an identifier) and a start of line marker. template javaBean{ 1 #package mypackage; # 2 #import java.util.Date; # 3 #public class MyClass{ # 4 # private Type field; 4 # 5 # public MyClass(){ # } # 8 # public MyClass(fieldList){ 9 # this.field=field; 8 # } # 6 # public Type getField(){ 6 # return this.field; 6 # } 6 # 7 # public void setField(Type field){ 7 # this.field=field; 7 # } 7 # #} } The labels serve to delineate individual lines or blocks of code that can be manipulated by processing instructions. Likewise, processing instructions are first class constructs in the JTemplate language, as shown in the following code snippet: instructions for javaBean(appOptions, entity){ 1 once: mypackage = endWith('.',appOptions.basePackage) + 'model';3 2 when (hasDateField(entity)); 3 once: MyClass = toFirstUpper(entity.name); 4 foreach (field in entity.fields): Type=javaType(field), field=field.name; 5 once: MyClass = toFirstUpper(entity.name); 6 foreach (field in entity.fields): Type=javaType(field), field=field.name, Field=toUpper(field.name); 7 foreach (field in entity.fields): Type=javaType(field), field=field.name, Field=toUpper(field.name); 8 once : MyClass = toFirstUpper(entity.name), fieldList=getFieldList(entity); 9 foreach (field in entity.fields): field=field.name; } A processing instruction consists of a line or block label matching a label in the corresponding template, an expression specifying how the instruction should be processed (once, conditionally or iteratively) and an optional list of text replacements. Additionally, processing instructions accept arguments in the same way as a function declaration. The JTemplate Language The remainder of the JTemplate language consists of a subset of ECMAScript 5 (ECMA International April 2009) operating in strict mode. JTemplate is an interpreted, dynamically typed language. First-class types consist of integers, strings, doubles, Booleans, arrays, maps and functions. All variables must be declared and initialized before being referenced. Control structures include if/else, while, foreach and switch. The following incomplete code snippet shows how the JavaBean template described above might be generated: var model={ entities: [ {name: 'customer', fields: [ {name: 'lastName', type: 'char', maxLength: 50}, {name: 'firstName', type: 'char', maxLength: 50} ], references: [ {entity: 'address', cardinality: 'one-to-many'} ] }, {name: 'address', fields: [ {name: 'address1', type:'char', maxLength: 100}, {name: 'address2', type:'char', maxLength: 100} ] } ] }; var appOptions={basePackage: 'edu.columbia.w4115'}; var hasDateField=function(entity){ foreach (field in entity.fields){ if (field.type=='date'){ return true; } }4 return false; }; var main=function(){ var path='gen/'+replace(appOptions.basePackage,',','/')+'/model/'; mkDirs(path); foreach(entity in model.entities){ var text=javaBean(appOptions, entity); writeFile(path+toFirstUpper(entity.name)+'.java', text, true); } }; Development Environment Project web site: http://code.google.com/p/ojtemplate/ Source code repository: Anon SVN http://ojtemplate.googlecode.com/svn/trunk/jtemplate/ IDE: Eclipse/OcaIDE Build System: ocamlbuild Works Cited Apache Wicket. http://wicket.apache.org/. ECMA


View Full Document

Columbia COMS W4115 - JTemplate

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download JTemplate
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view JTemplate and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view JTemplate 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?