Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-11-29 16:37:48 -0500
committerpelder2007-11-29 16:37:48 -0500
commit197281481fe62828be41f62e1f2fbe1df41520de (patch)
tree2c2e1d8fc7ac8d010a44bdc8225a697960603495
parentbff2aa187fff5e6343666c2ccfe86ca416ff1c94 (diff)
downloadorg.eclipse.jet-197281481fe62828be41f62e1f2fbe1df41520de.tar.gz
org.eclipse.jet-197281481fe62828be41f62e1f2fbe1df41520de.tar.xz
org.eclipse.jet-197281481fe62828be41f62e1f2fbe1df41520de.zip
[211516] Performance: Create a factory class for tag libraries
-rw-r--r--plugins/org.eclipse.jet/plugin.xml12
-rw-r--r--plugins/org.eclipse.jet/schema/tagLibraries.exsd10
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagDefinitionImpl.java24
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagLibraryImpl.java25
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/TagFactory.java134
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/format/TagFactory.java77
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/TagFactory.java74
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/TagFactory.java68
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagInstanceFactory.java25
9 files changed, 436 insertions, 13 deletions
diff --git a/plugins/org.eclipse.jet/plugin.xml b/plugins/org.eclipse.jet/plugin.xml
index b111c05..b44d4f0 100644
--- a/plugins/org.eclipse.jet/plugin.xml
+++ b/plugins/org.eclipse.jet/plugin.xml
@@ -37,7 +37,8 @@
<tagLibrary
id="controlTags"
name="Standard JET2 Control Tags"
- standardPrefix="c">
+ standardPrefix="c"
+ tagFactory="org.eclipse.jet.internal.taglib.control.TagFactory">
<description>
Control flow and data management tags. This tags allow templates to evaluate conditions, perform loops and access and set information in the template input.
</description><emptyTag class="org.eclipse.jet.internal.taglib.control.AddElementTag" name="addElement" whenContainingLineIsEmpty="remove">
@@ -559,7 +560,8 @@ If this tag is not directly contained by a 'choose' tag, then an error results.
<tagLibrary
id="workspaceTags"
name="Standard JET2 Workspace Tags"
- standardPrefix="ws">
+ standardPrefix="ws"
+ tagFactory="org.eclipse.jet.internal.taglib.workspace.TagFactory">
<description>
A library of tags for performing actions against the Eclipse workspace.
@@ -696,7 +698,8 @@ The 'project' tag may contain other tags. Contained 'folder' and 'file' tags wil
<tagLibrary
id="javaTags"
name="Standard JET2 Java Tags"
- standardPrefix="java">
+ standardPrefix="java"
+ tagFactory="org.eclipse.jet.internal.taglib.java.TagFactory">
<description>
Tags useful in generating Java code.
@@ -895,7 +898,8 @@ This tag may occur only once in a template.
<tagLibrary
id="formatTags"
name="Standard JET2 Format Tags"
- standardPrefix="f">
+ standardPrefix="f"
+ tagFactory="org.eclipse.jet.internal.taglib.format.TagFactory">
<description>
Standard utility tags that rewrite their content in a different format.
diff --git a/plugins/org.eclipse.jet/schema/tagLibraries.exsd b/plugins/org.eclipse.jet/schema/tagLibraries.exsd
index 284cdac..8ad5901 100644
--- a/plugins/org.eclipse.jet/schema/tagLibraries.exsd
+++ b/plugins/org.eclipse.jet/schema/tagLibraries.exsd
@@ -87,6 +87,16 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="tagFactory" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jet.taglib.TagInstanceFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagDefinitionImpl.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagDefinitionImpl.java
index 7ff4978..04078ea 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagDefinitionImpl.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagDefinitionImpl.java
@@ -12,7 +12,7 @@
*
* </copyright>
*
- * $Id: ExtensionTagDefinitionImpl.java,v 1.1 2007/04/04 14:59:32 pelder Exp $
+ * $Id: ExtensionTagDefinitionImpl.java,v 1.2 2007/11/29 21:37:48 pelder Exp $
*/
package org.eclipse.jet.internal.taglib;
@@ -28,6 +28,7 @@ import org.eclipse.jet.taglib.CustomTagKind;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagAttributeDefinition;
import org.eclipse.jet.taglib.TagDefinition;
+import org.eclipse.jet.taglib.TagInstanceFactory;
import org.eclipse.jet.taglib.TagLibrary;
/**
@@ -62,7 +63,7 @@ public class ExtensionTagDefinitionImpl extends TagDefinitionImpl implements Tag
private final IConfigurationElement configElement2;
- public static ExtensionTagDefinitionImpl createInstance(String tagName, IConfigurationElement configElement, CustomTagKind kind, TagLibrary tagLibrary)
+ public static ExtensionTagDefinitionImpl createInstance(String tagName, IConfigurationElement configElement, CustomTagKind kind, ExtensionTagLibraryImpl tagLibrary)
{
boolean deprecated = Boolean.valueOf(configElement.getAttribute(DEPRECATED__ATTR)).booleanValue();
boolean customContentProcessing = CONTENT_PROCESSING__VALUE__CUSTOM.equals(configElement.getAttribute(CONTENT_PROCESSING__ATTR));
@@ -126,13 +127,18 @@ public class ExtensionTagDefinitionImpl extends TagDefinitionImpl implements Tag
*/
public CustomTag newTagElement() throws JET2TagException
{
- try
- {
- return (CustomTag)configElement2.createExecutableExtension(CLASS__ATTR);
- }
- catch (CoreException e)
- {
- throw new JET2TagException(e);
+ TagInstanceFactory factory = ((ExtensionTagLibraryImpl)getTagLibrary()).getTagInstanceFactory();
+ if(factory != null) {
+ return factory.createCustomTag(getName());
+ } else {
+ try
+ {
+ return (CustomTag)configElement2.createExecutableExtension(CLASS__ATTR);
+ }
+ catch (CoreException e)
+ {
+ throw new JET2TagException(e);
+ }
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagLibraryImpl.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagLibraryImpl.java
index 87ed9f0..689bc78 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagLibraryImpl.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/ExtensionTagLibraryImpl.java
@@ -23,9 +23,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.jet.internal.InternalJET2Platform;
import org.eclipse.jet.taglib.CustomTagKind;
import org.eclipse.jet.taglib.TagDefinition;
+import org.eclipse.jet.taglib.TagInstanceFactory;
import org.eclipse.jet.taglib.TagLibrary;
@@ -85,9 +88,14 @@ public class ExtensionTagLibraryImpl implements TagLibrary
private static final String[] EMPTY_TAGNAME_ARRAY = new String [0];
+ private final IConfigurationElement configElement;
+
+ private final TagInstanceFactory tagInstanceFactory;
+
public ExtensionTagLibraryImpl(String id, IConfigurationElement configElement)
{
this.id = id;
+ this.configElement = configElement;
deprecated = Boolean.valueOf(configElement.getAttribute(DEPRECATED__ATTR)).booleanValue();
@@ -109,6 +117,18 @@ public class ExtensionTagLibraryImpl implements TagLibrary
tagMap.put(tagName, ExtensionTagDefinitionImpl.createInstance(tagName, children[i], kind, this));
}
}
+
+ TagInstanceFactory factory = null;
+ try
+ {
+ factory = (TagInstanceFactory)configElement.createExecutableExtension("tagFactory"); //$NON-NLS-1$
+ }
+ catch (CoreException e)
+ {
+ // ignore
+ InternalJET2Platform.log(e.getStatus());
+ }
+ tagInstanceFactory = factory;
}
/**
@@ -182,4 +202,9 @@ public class ExtensionTagLibraryImpl implements TagLibrary
return description;
}
+ public TagInstanceFactory getTagInstanceFactory()
+ {
+ return tagInstanceFactory;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/TagFactory.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/TagFactory.java
new file mode 100644
index 0000000..d83c47c
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/TagFactory.java
@@ -0,0 +1,134 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TagFactory.java,v 1.1 2007/11/29 21:37:48 pelder Exp $
+ */
+package org.eclipse.jet.internal.taglib.control;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.taglib.CustomTag;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.taglib.TagInstanceFactory;
+
+/**
+ * Tag Factory for controlTags
+ */
+public class TagFactory implements TagInstanceFactory
+{
+
+ private final Map tagOrdinalByName;
+
+ /**
+ *
+ */
+ public TagFactory()
+ {
+ tagOrdinalByName = new HashMap(27);
+
+ tagOrdinalByName.put("addElement",new Integer(1)); //$NON-NLS-1$
+ tagOrdinalByName.put("addTextElement",new Integer(2)); //$NON-NLS-1$
+ tagOrdinalByName.put("case",new Integer(3)); //$NON-NLS-1$
+ tagOrdinalByName.put("choose",new Integer(4)); //$NON-NLS-1$
+ tagOrdinalByName.put("copyElement",new Integer(5)); //$NON-NLS-1$
+ tagOrdinalByName.put("dump",new Integer(6)); //$NON-NLS-1$
+ tagOrdinalByName.put("get",new Integer(7)); //$NON-NLS-1$
+ tagOrdinalByName.put("if",new Integer(8)); //$NON-NLS-1$
+ tagOrdinalByName.put("include",new Integer(9)); //$NON-NLS-1$
+ tagOrdinalByName.put("initialCode",new Integer(10)); //$NON-NLS-1$
+ tagOrdinalByName.put("invokeTransform",new Integer(11)); //$NON-NLS-1$
+ tagOrdinalByName.put("iterate",new Integer(12)); //$NON-NLS-1$
+ tagOrdinalByName.put("load",new Integer(13)); //$NON-NLS-1$
+ tagOrdinalByName.put("loadContent",new Integer(14)); //$NON-NLS-1$
+ tagOrdinalByName.put("log",new Integer(15)); //$NON-NLS-1$
+ tagOrdinalByName.put("marker",new Integer(16)); //$NON-NLS-1$
+ tagOrdinalByName.put("otherwise",new Integer(17)); //$NON-NLS-1$
+ tagOrdinalByName.put("override",new Integer(18)); //$NON-NLS-1$
+ tagOrdinalByName.put("removeElement",new Integer(19)); //$NON-NLS-1$
+ tagOrdinalByName.put("replaceStrings",new Integer(20)); //$NON-NLS-1$
+ tagOrdinalByName.put("set",new Integer(21)); //$NON-NLS-1$
+ tagOrdinalByName.put("setVariable",new Integer(22)); //$NON-NLS-1$
+ tagOrdinalByName.put("stringTokens",new Integer(23)); //$NON-NLS-1$
+ tagOrdinalByName.put("userRegion",new Integer(24)); //$NON-NLS-1$
+ tagOrdinalByName.put("visit",new Integer(25)); //$NON-NLS-1$
+ tagOrdinalByName.put("visitor",new Integer(26)); //$NON-NLS-1$
+ tagOrdinalByName.put("when",new Integer(27)); //$NON-NLS-1$
+ }
+
+ public CustomTag createCustomTag(String name)
+ {
+ Integer ordinal = (Integer)tagOrdinalByName.get(name);
+
+ switch(ordinal == null ? 0 : ordinal.intValue()) {
+ case 1: // addElement
+ return new org.eclipse.jet.internal.taglib.control.AddElementTag();
+ case 2: // addTextElement
+ return new org.eclipse.jet.internal.taglib.control.AddTextElementTag();
+ case 3: // case
+ return new org.eclipse.jet.internal.taglib.control.WhenTag();
+ case 4: // choose
+ return new org.eclipse.jet.internal.taglib.control.ChooseTag();
+ case 5: // copyElement
+ return new org.eclipse.jet.internal.taglib.control.CopyElementTag();
+ case 6: // dump
+ return new org.eclipse.jet.internal.taglib.control.DumpTag();
+ case 7: // get
+ return new org.eclipse.jet.internal.taglib.control.GetTag();
+ case 8: // if
+ return new org.eclipse.jet.internal.taglib.control.IfTag();
+ case 9: // include
+ return new org.eclipse.jet.internal.taglib.control.IncludeTag();
+ case 10: // initialCode
+ return new org.eclipse.jet.internal.taglib.control.InitialCodeTag();
+ case 11: // invokeTransform
+ return new org.eclipse.jet.internal.taglib.control.InvokeTransformTag();
+ case 12: // iterate
+ return new org.eclipse.jet.internal.taglib.control.IterateTag();
+ case 13: // load
+ return new org.eclipse.jet.internal.taglib.control.LoadTag();
+ case 14: // loadContent
+ return new org.eclipse.jet.internal.taglib.control.LoadContentTag();
+ case 15: // log
+ return new org.eclipse.jet.internal.taglib.control.LogTag();
+ case 16: // marker
+ return new org.eclipse.jet.internal.taglib.control.MarkerTag();
+ case 17: // otherwise
+ return new org.eclipse.jet.internal.taglib.control.OtherwiseTag();
+ case 18: // override
+ return new org.eclipse.jet.internal.taglib.control.OverrideTag();
+ case 19: // removeElement
+ return new org.eclipse.jet.internal.taglib.control.RemoveElementTag();
+ case 20: // replaceStrings
+ return new org.eclipse.jet.internal.taglib.control.ReplaceStringsTag();
+ case 21: // set
+ return new org.eclipse.jet.internal.taglib.control.SetTag();
+ case 22: // setVariable
+ return new org.eclipse.jet.internal.taglib.control.SetVariableTag();
+ case 23: // stringTokens
+ return new org.eclipse.jet.internal.taglib.control.StringTokensTag();
+ case 24: // userRegion
+ return new org.eclipse.jet.internal.taglib.control.UserRegionTag();
+ case 25: // visit
+ return new org.eclipse.jet.internal.taglib.control.VisitTag();
+ case 26: // visitor
+ return new org.eclipse.jet.internal.taglib.control.VisitorTag();
+ case 27: // when
+ return new org.eclipse.jet.internal.taglib.control.WhenTag();
+ default:
+ throw new JET2TagException("Unknown Tag: " + name); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/format/TagFactory.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/format/TagFactory.java
new file mode 100644
index 0000000..f3ce582
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/format/TagFactory.java
@@ -0,0 +1,77 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TagFactory.java,v 1.1 2007/11/29 21:37:48 pelder Exp $
+ */
+package org.eclipse.jet.internal.taglib.format;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.taglib.CustomTag;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.taglib.TagInstanceFactory;
+
+/**
+ * Tag Factory for formatTags
+ */
+public class TagFactory implements TagInstanceFactory
+{
+
+ private final Map tagOrdinalByName;
+
+ /**
+ *
+ */
+ public TagFactory()
+ {
+ tagOrdinalByName = new HashMap(8);
+
+ tagOrdinalByName.put("formatNow",new Integer(1)); //$NON-NLS-1$
+ tagOrdinalByName.put("lc",new Integer(2)); //$NON-NLS-1$
+ tagOrdinalByName.put("milliseconds",new Integer(3)); //$NON-NLS-1$
+ tagOrdinalByName.put("replaceAll",new Integer(4)); //$NON-NLS-1$
+ tagOrdinalByName.put("strip",new Integer(5)); //$NON-NLS-1$
+ tagOrdinalByName.put("uc",new Integer(6)); //$NON-NLS-1$
+ tagOrdinalByName.put("unique",new Integer(7)); //$NON-NLS-1$
+ tagOrdinalByName.put("uuid",new Integer(8)); //$NON-NLS-1$
+ }
+
+ public CustomTag createCustomTag(String name)
+ {
+ Integer ordinal = (Integer)tagOrdinalByName.get(name);
+
+ switch(ordinal == null ? 0 : ordinal.intValue()) {
+ case 1: // formatNow
+ return new org.eclipse.jet.internal.taglib.format.FormatNowTag();
+ case 2: // lc
+ return new org.eclipse.jet.internal.taglib.format.LowerCaseTag();
+ case 3: // milliseconds
+ return new org.eclipse.jet.internal.taglib.format.MillisecondsTag();
+ case 4: // replaceAll
+ return new org.eclipse.jet.internal.taglib.format.ReplaceAllTag();
+ case 5: // strip
+ return new org.eclipse.jet.internal.taglib.format.StripTag();
+ case 6: // uc
+ return new org.eclipse.jet.internal.taglib.format.UpperCaseTag();
+ case 7: // unique
+ return new org.eclipse.jet.internal.taglib.format.UniqueTag();
+ case 8: // uuid
+ return new org.eclipse.jet.internal.taglib.format.UuidTag();
+ default:
+ throw new JET2TagException("Unknown Tag: " + name); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/TagFactory.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/TagFactory.java
new file mode 100644
index 0000000..f0e13c2
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/TagFactory.java
@@ -0,0 +1,74 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TagFactory.java,v 1.1 2007/11/29 21:37:48 pelder Exp $
+ */
+package org.eclipse.jet.internal.taglib.java;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.taglib.CustomTag;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.taglib.TagInstanceFactory;
+
+/**
+ * Tag Factory for javaTags
+ */
+public class TagFactory implements TagInstanceFactory
+{
+
+ private final Map tagOrdinalByName;
+
+ /**
+ *
+ */
+ public TagFactory()
+ {
+ tagOrdinalByName = new HashMap(7);
+
+ tagOrdinalByName.put("class",new Integer(1)); //$NON-NLS-1$
+ tagOrdinalByName.put("impliedImport",new Integer(2)); //$NON-NLS-1$
+ tagOrdinalByName.put("import",new Integer(3)); //$NON-NLS-1$
+ tagOrdinalByName.put("importsLocation",new Integer(4)); //$NON-NLS-1$
+ tagOrdinalByName.put("merge",new Integer(5)); //$NON-NLS-1$
+ tagOrdinalByName.put("package",new Integer(6)); //$NON-NLS-1$
+ tagOrdinalByName.put("resource",new Integer(7)); //$NON-NLS-1$
+ }
+
+ public CustomTag createCustomTag(String name)
+ {
+ Integer ordinal = (Integer)tagOrdinalByName.get(name);
+
+ switch(ordinal == null ? 0 : ordinal.intValue()) {
+ case 1: // class
+ return new org.eclipse.jet.internal.taglib.java.JavaClassTag();
+ case 2: // impliedImport
+ return new org.eclipse.jet.internal.taglib.java.ImpliedImportTag();
+ case 3: // import
+ return new org.eclipse.jet.internal.taglib.java.ImportTag();
+ case 4: // importsLocation
+ return new org.eclipse.jet.internal.taglib.java.ImportsLocationTag();
+ case 5: // merge
+ return new org.eclipse.jet.internal.taglib.java.MergeTag();
+ case 6: // package
+ return new org.eclipse.jet.internal.taglib.java.PackageTag();
+ case 7: // resource
+ return new org.eclipse.jet.internal.taglib.java.JavaResourceTag();
+ default:
+ throw new JET2TagException("Unknown Tag: " + name); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/TagFactory.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/TagFactory.java
new file mode 100644
index 0000000..e363289
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/TagFactory.java
@@ -0,0 +1,68 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TagFactory.java,v 1.1 2007/11/29 21:37:48 pelder Exp $
+ */
+package org.eclipse.jet.internal.taglib.workspace;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.taglib.CustomTag;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.taglib.TagInstanceFactory;
+
+/**
+ * Tag Factory for workspaceTags
+ */
+public class TagFactory implements TagInstanceFactory
+{
+
+ private final Map tagOrdinalByName;
+
+ /**
+ *
+ */
+ public TagFactory()
+ {
+ tagOrdinalByName = new HashMap(5);
+
+ tagOrdinalByName.put("copyFile",new Integer(1)); //$NON-NLS-1$
+ tagOrdinalByName.put("file",new Integer(2)); //$NON-NLS-1$
+ tagOrdinalByName.put("folder",new Integer(3)); //$NON-NLS-1$
+ tagOrdinalByName.put("project",new Integer(4)); //$NON-NLS-1$
+ tagOrdinalByName.put("rebuildWorkspace",new Integer(5)); //$NON-NLS-1$
+ }
+
+ public CustomTag createCustomTag(String name)
+ {
+ Integer ordinal = (Integer)tagOrdinalByName.get(name);
+
+ switch(ordinal == null ? 0 : ordinal.intValue()) {
+ case 1: // copyFile
+ return new org.eclipse.jet.internal.taglib.workspace.CopyFileTag();
+ case 2: // file
+ return new org.eclipse.jet.internal.taglib.workspace.FileTag();
+ case 3: // folder
+ return new org.eclipse.jet.internal.taglib.workspace.FolderTag();
+ case 4: // project
+ return new org.eclipse.jet.internal.taglib.workspace.ProjectTag();
+ case 5: // rebuildWorkspace
+ return new org.eclipse.jet.internal.taglib.workspace.RebuildWorkspaceTag();
+ default:
+ throw new JET2TagException("Unknown Tag: " + name); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagInstanceFactory.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagInstanceFactory.java
new file mode 100644
index 0000000..4c7cc5e
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagInstanceFactory.java
@@ -0,0 +1,25 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TagInstanceFactory.java,v 1.1 2007/11/29 21:37:48 pelder Exp $
+ */
+package org.eclipse.jet.taglib;
+
+/**
+ * Define behavior of a factory for tags in a class library
+ */
+public interface TagInstanceFactory
+{
+ CustomTag createCustomTag(String name);
+}

Back to the top