Skip to main content
summaryrefslogtreecommitdiffstats
blob: f5e17fddaa191d21b956ff87c89ba5cbf532a219 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
 *
 * Copyright (c) <f:formatNow pattern="yyyy"/> 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
 *
 */
package <c:get select="$tagLibrary/@pkgFactory"/>;

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 <c:get select="$tagLibrary/@id"/>
 */
public class <c:get select="$tagLibrary/@clsFactory"/> implements TagInstanceFactory
{

  private final Map tagOrdinalByName;
  
  /**
   * 
   */
  public <c:get select="$tagLibrary/@clsFactory"/>()
  {
    tagOrdinalByName = new HashMap(<c:get select="$tagLibrary/@numTags"/>);

<c:iterate select="$tagLibrary/*['Tag' = substring(local-name(), string-length(local-name()) - 2, 3)]" var="tag">
    tagOrdinalByName.put("<c:get select="$tag/@name"/>",new Integer(<c:get select="$tag/@ordinal"/>)); //$NON-NLS-1$
</c:iterate>
  }

  public CustomTag createCustomTag(String name)
  {
    Integer ordinal = (Integer)tagOrdinalByName.get(name);
    
    switch(ordinal == null ? 0 : ordinal.intValue()) {
<c:iterate select="$tagLibrary/*['Tag' = substring(local-name(), string-length(local-name()) - 2, 3)]" var="tag">
      case <c:get select="$tag/@ordinal"/>: // <c:get select="$tag/@name"/>
        return new <c:get select="$tag/@class"/>();
</c:iterate>
      default:
        throw new JET2TagException("Unknown Tag: " + name); //$NON-NLS-1$
    }
  }

}

Back to the top