Changeset 3013

Show
Ignore:
Timestamp:
17/08/07 10:56:07 (4 years ago)
Author:
michael
Message:

Add support for old JSTL core namespace as a deprecated namespace

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build.properties

    r2936 r3013  
    11project.name=xtc 
    2 project.rev=0.4 
     2project.rev=0.4.1 
    33project.status=integration 
  • trunk/src/main/java/org/sarugo/xtc/tag/AbstractTagLibrary.java

    r2915 r3013  
    1818import java.lang.reflect.Method; 
    1919import java.net.URL; 
     20import java.util.ArrayList; 
    2021import java.util.HashMap; 
     22import java.util.List; 
    2123import java.util.Map; 
     24import java.util.logging.Logger; 
    2225 
    2326import javax.el.ELException; 
     
    3336 */ 
    3437public abstract class AbstractTagLibrary implements TagLibrary { 
     38         
     39        private static Logger LOG = Logger.getLogger("xtc.compiler"); 
    3540     
    3641    private static class HandlerFactory implements TagHandlerFactory { 
     
    7883    } 
    7984     
    80     private final Map factories; 
    81  
    82     private final String namespace; 
    83  
    84     private final Map functions; 
     85    private final Map<String, TagHandlerFactory> factories; 
     86 
     87    private final List<String> namespace; 
     88 
     89    private final Map<String, Method> functions; 
    8590 
    8691    public AbstractTagLibrary(String namespace) { 
    87         this.namespace = namespace; 
    88         this.factories = new HashMap(); 
    89         this.functions = new HashMap(); 
     92        this.namespace = new ArrayList<String>(); 
     93        this.namespace.add(namespace); 
     94        this.factories = new HashMap<String, TagHandlerFactory>(); 
     95        this.functions = new HashMap<String, Method>(); 
     96    } 
     97     
     98    protected void addNamespaceAlias(String namespace) { 
     99        this.namespace.add(namespace); 
    90100    } 
    91101 
     
    130140 
    131141    public boolean containsNamespace(String ns) { 
    132         return this.namespace.equals(ns); 
     142        boolean contained = this.namespace.get(0).equals(ns); 
     143        if (!contained && this.namespace.contains(ns)) { 
     144                LOG.warning("Use of deprecated namespace: " + ns); 
     145                contained = true; 
     146        } 
     147        return contained; 
    133148    } 
    134149 
    135150    public boolean containsTagHandler(String ns, String localName) { 
    136         if (this.namespace.equals(ns)) { 
     151        if (containsNamespace(ns)) { 
    137152            if (this.factories.containsKey(localName)) { 
    138153                return true; 
     
    144159    public TagHandler createTagHandler(String ns, String localName, 
    145160            TagConfig tag) throws TemplateException { 
    146         if (this.namespace.equals(ns)) { 
     161        if (containsNamespace(ns)) { 
    147162            TagHandlerFactory f = (TagHandlerFactory) this.factories 
    148163                    .get(localName); 
     
    155170 
    156171    public boolean containsFunction(String ns, String name) { 
    157         if (this.namespace.equals(ns)) { 
     172        if (containsNamespace(ns)) { 
    158173            return this.functions.containsKey(name); 
    159174        } 
     
    162177 
    163178    public Method createFunction(String ns, String name) { 
    164         if (this.namespace.equals(ns)) { 
     179        if (containsNamespace(ns)) { 
    165180            return (Method) this.functions.get(name); 
    166181        } 
     
    187202 
    188203    public String getNamespace() { 
    189         return namespace
     204        return namespace.get(0)
    190205    } 
    191206} 
  • trunk/src/main/java/org/sarugo/xtc/tag/jstl/core/JstlCoreLibrary.java

    r2975 r3013  
    1919/** 
    2020 * @author Jacob Hookom 
    21  * @version $Id: JstlCoreLibrary.java,v 1.4 2006/01/07 15:32:07 jhook Exp $ 
     21 * @author Michael Terrington 
    2222 */ 
    2323public final class JstlCoreLibrary extends AbstractTagLibrary { 
     
    2525    public final static String Namespace = "http://java.sun.com/jsp/jstl/core"; 
    2626 
    27     public final static JstlCoreLibrary Instance = new JstlCoreLibrary(); 
    28  
    2927    public JstlCoreLibrary() { 
    3028        super(Namespace); 
     29        this.addNamespaceAlias("http://java.sun.com/jstl/core"); 
    3130 
    3231        this.addTagHandler("if", IfHandler.class);