summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-09-14 11:03:36 (EDT)
committerpelder2006-09-14 11:03:36 (EDT)
commita1802517b091b04a456912b47c0ca0d1e5b1a42c (patch)
tree59ff85d2e6d5dc4e438bf747f901b38e45616722
parenta9a1ff16805264620b239d961de406ff3f6e93f1 (diff)
downloadorg.eclipse.jet-a1802517b091b04a456912b47c0ca0d1e5b1a42c.zip
org.eclipse.jet-a1802517b091b04a456912b47c0ca0d1e5b1a42c.tar.gz
org.eclipse.jet-a1802517b091b04a456912b47c0ca0d1e5b1a42c.tar.bz2
Regenerated template loader.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java100
1 files changed, 49 insertions, 51 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
index 7939b58..e6c9044 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
@@ -9,8 +9,37 @@ import org.eclipse.jet.JET2Template;
public class CodeGenTemplateLoader implements JET2TemplateLoader, JET2TemplateLoaderExtension {
- private interface TemplateFactoryMethod {
- public abstract JET2Template newTemplate();
+ private static final class TemplateFactoryMethod {
+
+ private final String templatePath;
+ private final String templateClass;
+
+ public TemplateFactoryMethod(String templatePath, String templateClass) {
+ this.templatePath = templatePath;
+ this.templateClass = templateClass;
+
+ }
+
+ public String getTemplateClass() {
+ return templateClass;
+ }
+
+ public String getTemplatePath() {
+ return templatePath;
+ }
+
+ public JET2Template newTemplate() {
+ JET2Template template = null;
+ try {
+ template = (JET2Template) Class.forName(templateClass).newInstance();
+ } catch (InstantiationException e) {
+ } catch (IllegalAccessException e) {
+ } catch (ClassNotFoundException e) {
+ }
+ return template;
+ }
+
+
}
private Map pathToFactoryMap = null;
@@ -23,60 +52,29 @@ public class CodeGenTemplateLoader implements JET2TemplateLoader, JET2TemplateLo
public JET2Template getTemplate(String templatePath) {
if(pathToFactoryMap == null) {
- pathToFactoryMap = new HashMap(8);
- pathToFactoryMap.put("templates/writeJavaExpression.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate();
- }
- });
- pathToFactoryMap.put("templates/jet2java.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator();
- }
- });
- pathToFactoryMap.put("templates/xmlStart.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.XMLStartGenerator();
- }
- });
- pathToFactoryMap.put("templates/main.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.DummyMain();
- }
- });
- pathToFactoryMap.put("templates/jet2transform.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator();
- }
- });
- pathToFactoryMap.put("templates/xmlEnd.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.XMLEndGenerator();
- }
- });
- pathToFactoryMap.put("templates/tagDataDeclarations.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator();
- }
- });
- pathToFactoryMap.put("templates/writeTextElement.jet", //$NON-NLS-1$
- new TemplateFactoryMethod() {
- public JET2Template newTemplate() {
- return new org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate();
- }
- });
+ initPathToFactoryMap();
}
TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
}
+ private void addTemplate(String templatePath, String templateClass) {
+ pathToFactoryMap.put(templatePath, //$NON-NLS-1$
+ new TemplateFactoryMethod(templatePath, templateClass));
+ }
+
+ private void initPathToFactoryMap() {
+ pathToFactoryMap = new HashMap(8);
+ addTemplate("templates/writeJavaExpression.jet", "org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/xmlStart.jet", "org.eclipse.jet.internal.compiler.templates.XMLStartGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/main.jet", "org.eclipse.jet.internal.compiler.templates.DummyMain" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/jet2transform.jet", "org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/xmlEnd.jet", "org.eclipse.jet.internal.compiler.templates.XMLEndGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/tagDataDeclarations.jet", "org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/writeTextElement.jet", "org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
public void setDelegateLoader(JET2TemplateLoader loader) {
this.delegate = loader;
}