- JSP 2.1 API fixes.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 28 Jul 2006 13:57:53 +0000 (13:57 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 28 Jul 2006 13:57:53 +0000 (13:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@426537 13f79535-47bb-0310-9956-ffa450edef68

21 files changed:
java/javax/el/ArrayELResolver.java
java/javax/el/BeanELResolver.java
java/javax/el/CompositeELResolver.java
java/javax/el/ELContextListener.java
java/javax/el/ELResolver.java
java/javax/el/ListELResolver.java
java/javax/el/MapELResolver.java
java/javax/servlet/jsp/JspContext.java
java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
java/javax/servlet/jsp/tagext/SimpleTagSupport.java
java/javax/servlet/jsp/tagext/TagData.java
java/javax/servlet/jsp/tagext/TagLibraryInfo.java
java/javax/servlet/jsp/tagext/TagLibraryValidator.java
java/javax/servlet/jsp/tagext/TagSupport.java
java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java
java/org/apache/jasper/compiler/JspDocumentParser.java
java/org/apache/jasper/compiler/Parser.java
java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
java/org/apache/jasper/runtime/JspContextWrapper.java
java/org/apache/jasper/runtime/PageContextImpl.java

index ec81298..28dcc82 100644 (file)
@@ -103,7 +103,7 @@ public class ArrayELResolver extends ELResolver {
                return this.readOnly;
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
                if (base != null && base.getClass().isArray()) {
                        FeatureDescriptor[] descs = new FeatureDescriptor[Array.getLength(base)];
                        for (int i = 0; i < descs.length; i++) {
index 95bcafe..3c0820c 100644 (file)
@@ -17,6 +17,7 @@
 package javax.el;
 
 import java.beans.BeanInfo;
+import java.beans.FeatureDescriptor;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
@@ -129,7 +130,7 @@ public class BeanELResolver extends ELResolver {
                                || this.property(context, base, property).isReadOnly();
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
                if (context == null) {
                        throw new NullPointerException();
                }
@@ -145,7 +146,7 @@ public class BeanELResolver extends ELResolver {
                                pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
                                pds[i].setValue(TYPE, pds[i].getPropertyType());
                        }
-                       return Arrays.asList(pds).iterator();
+                       return Arrays.asList((FeatureDescriptor[]) pds).iterator();
                } catch (IntrospectionException e) {
                        //
                }
@@ -165,7 +166,7 @@ public class BeanELResolver extends ELResolver {
                return null;
        }
 
-       private final static class BeanProperties {
+       protected final static class BeanProperties {
                private final Map<String, BeanProperty> properties;
 
                private final Class<?> type;
@@ -200,7 +201,7 @@ public class BeanELResolver extends ELResolver {
         }
        }
 
-       private final static class BeanProperty {
+    protected final static class BeanProperty {
                private final Class type;
 
                private final Class owner;
index 84789b7..6d64eb2 100644 (file)
@@ -16,6 +16,7 @@
 
 package javax.el;
 
+import java.beans.FeatureDescriptor;
 import java.util.Iterator;
 
 public class CompositeELResolver extends ELResolver {
@@ -84,7 +85,7 @@ public class CompositeELResolver extends ELResolver {
                return false;
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
                return new FeatureIterator(context, base, this.resolvers, this.size);
        }
 
@@ -115,7 +116,7 @@ public class CompositeELResolver extends ELResolver {
                return null;
        }
 
-       private final static class FeatureIterator implements Iterator {
+       private final static class FeatureIterator implements Iterator<FeatureDescriptor> {
 
                private final ELContext context;
 
@@ -152,7 +153,7 @@ public class CompositeELResolver extends ELResolver {
                        return this.itr != null;
                }
 
-               public Object next() {
+               public FeatureDescriptor next() {
                        Object result = null;
                        if (this.itr != null) {
                                if (this.itr.hasNext()) {
@@ -163,7 +164,7 @@ public class CompositeELResolver extends ELResolver {
                                        }
                                }
                        }
-                       return result;
+                       return (FeatureDescriptor) result;
                }
 
                public void remove() {
index 5ddfa55..25a128a 100644 (file)
@@ -20,7 +20,7 @@ package javax.el;
  * @author Jacob Hookom [jacob/hookom.net]
  *
  */
-public interface ELContextListener {
+public interface ELContextListener extends java.util.EventListener {
     
     public void contextCreated(ELContextEvent event);
 
index 722e934..de01d8c 100644 (file)
@@ -62,7 +62,7 @@ public abstract class ELResolver {
 
     public abstract boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException;
     
-    public abstract Iterator getFeatureDescriptors(ELContext context, Object base);
+    public abstract Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base);
     
     public abstract Class<?> getCommonPropertyType(ELContext context, Object base);
 }
index 0d86446..7709745 100644 (file)
@@ -127,7 +127,7 @@ public class ListELResolver extends ELResolver {
                return this.readOnly;
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
                if (base instanceof List) {
                        FeatureDescriptor[] descs = new FeatureDescriptor[((List) base).size()];
                        for (int i = 0; i < descs.length; i++) {
index fb95926..fb8622c 100644 (file)
@@ -107,10 +107,10 @@ public class MapELResolver extends ELResolver {
                return this.readOnly;
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
                if (base instanceof Map) {
                        Iterator itr = ((Map) base).keySet().iterator();
-                       List feats = new ArrayList();
+                       List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>();
                        Object key;
                        FeatureDescriptor desc;
                        while (itr.hasNext()) {
index 6db775d..0d2e394 100644 (file)
@@ -205,7 +205,7 @@ public abstract class JspContext {
      *     invalidated.
      */
 
-    abstract public Enumeration getAttributeNamesInScope(int scope);
+    abstract public Enumeration<String> getAttributeNamesInScope(int scope);
 
     /**
      * The current value of the out object (a JspWriter).
index 339ed29..6cbda41 100644 (file)
@@ -102,7 +102,7 @@ public class ImplicitObjectELResolver extends ELResolver {
         return null;
     }
 
-    public Class<?> getType(ELContext context, Object base, Object property)
+    public Class getType(ELContext context, Object base, Object property)
             throws NullPointerException, PropertyNotFoundException, ELException {
         if (context == null) {
             throw new NullPointerException();
@@ -150,7 +150,7 @@ public class ImplicitObjectELResolver extends ELResolver {
         return false;
     }
 
-    public Iterator getFeatureDescriptors(ELContext context, Object base) {
+    public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
         List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>(
                 SCOPE_NAMES.length);
         FeatureDescriptor feat;
@@ -168,7 +168,7 @@ public class ImplicitObjectELResolver extends ELResolver {
         return feats.iterator();
     }
 
-    public Class<?> getCommonPropertyType(ELContext context, Object base) {
+    public Class<String> getCommonPropertyType(ELContext context, Object base) {
         if (base == null) {
             return String.class;
         }
index d57ca4a..aed837c 100644 (file)
@@ -40,7 +40,7 @@ public class ScopedAttributeELResolver extends ELResolver {
                return null;
        }
 
-       public Class<?> getType(ELContext context, Object base, Object property)
+       public Class getType(ELContext context, Object base, Object property)
                        throws NullPointerException, PropertyNotFoundException, ELException {
                if (context == null) {
                        throw new NullPointerException();
@@ -91,10 +91,10 @@ public class ScopedAttributeELResolver extends ELResolver {
                return false;
        }
 
-       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+       public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
 
                PageContext ctxt = (PageContext) context.getContext(JspContext.class);
-               List list = new ArrayList();
+               List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
                Enumeration e;
                Object value;
                String name;
@@ -173,7 +173,7 @@ public class ScopedAttributeELResolver extends ELResolver {
                }
        }
 
-       public Class<?> getCommonPropertyType(ELContext context, Object base) {
+       public Class<String> getCommonPropertyType(ELContext context, Object base) {
                if (base == null) {
                        return String.class;
                }
index 1824639..aa73029 100644 (file)
@@ -175,7 +175,7 @@ public class SimpleTagSupport
      * or is an instance of the class specified
      */
     public static final JspTag findAncestorWithClass(
-       JspTag from, Class klass) 
+       JspTag from, Class<?> klass) 
     {
        boolean isInterface = false;
 
index 58003ea..dbf5eea 100644 (file)
@@ -55,14 +55,14 @@ public class TagData implements Cloneable {
      */
     public TagData(Object[] atts[]) {
        if (atts == null) {
-           attributes = new Hashtable();
+           attributes = new Hashtable<String, Object>();
        } else {
-           attributes = new Hashtable(atts.length);
+           attributes = new Hashtable<String, Object>(atts.length);
        }
 
        if (atts != null) {
            for (int i = 0; i < atts.length; i++) {
-               attributes.put(atts[i][0], atts[i][1]);
+               attributes.put((String) atts[i][0], atts[i][1]);
            }
        }
     }
@@ -75,7 +75,7 @@ public class TagData implements Cloneable {
      *
      * @param attrs A hashtable to get the values from.
      */
-    public TagData(Hashtable attrs) {
+    public TagData(Hashtable<String, Object> attrs) {
         this.attributes = attrs;
     }
 
@@ -143,11 +143,11 @@ public class TagData implements Cloneable {
      *
      *@return An enumeration of the attributes in a TagData
      */
-    public java.util.Enumeration getAttributes() {
+    public java.util.Enumeration<String> getAttributes() {
         return attributes.keys();
     };
 
     // private data
 
-    private Hashtable attributes;      // the tagname/value map
+    private Hashtable<String, Object> attributes;      // the tagname/value map
 }
index 8a548bf..4667ca7 100644 (file)
@@ -225,6 +225,22 @@ abstract public class TagLibraryInfo {
     }
 
 
+    /**
+     * Returns an array of TagLibraryInfo objects representing the entire set 
+     * of tag libraries (including this TagLibraryInfo) imported by taglib 
+     * directives in the translation unit that references this TagLibraryInfo. 
+     * If a tag library is imported more than once and bound to different prefices, 
+     * only the TagLibraryInfo bound to the first prefix must be included 
+     * in the returned array.
+     * 
+     * @return Array of TagLibraryInfo objects representing the entire set 
+     * of tag libraries (including this TagLibraryInfo) imported by taglib 
+     * directives in the translation unit that references this TagLibraryInfo.
+     * @since 2.1
+     */
+    public abstract javax.servlet.jsp.tagext.TagLibraryInfo[] getTagLibraryInfos();
+    
+    
     // Protected fields
 
     /**
index 41acb81..a59a5f1 100644 (file)
@@ -94,7 +94,7 @@ abstract public class TagLibraryValidator {
      *
      * @param map A Map describing the init parameters
      */
-    public void setInitParameters(Map map) {
+    public void setInitParameters(Map<String, Object> map) {
        initParameters = map;
     }
 
@@ -105,7 +105,7 @@ abstract public class TagLibraryValidator {
      *
      * @return The init parameters as an immutable map.
      */
-    public Map getInitParameters() {
+    public Map<String, Object> getInitParameters() {
        return initParameters;
     }
 
@@ -138,6 +138,6 @@ abstract public class TagLibraryValidator {
     }
 
     // Private data
-    private Map initParameters;
+    private Map<String, Object> initParameters;
 
 }
index 1e6ca3c..f1a81c3 100644 (file)
@@ -228,7 +228,7 @@ public class TagSupport implements IterationTag, Serializable {
 
     public void setValue(String k, Object o) {
        if (values == null) {
-           values = new Hashtable();
+           values = new Hashtable<String, Object>();
        }
        values.put(k, o);
     }
@@ -267,7 +267,7 @@ public class TagSupport implements IterationTag, Serializable {
      *     or null or an empty Enumeration if no values have been set.
      */
 
-    public Enumeration getValues() {
+    public Enumeration<String> getValues() {
        if (values == null) {
            return null;
        }
@@ -277,7 +277,7 @@ public class TagSupport implements IterationTag, Serializable {
     // private fields
 
     private   Tag         parent;
-    private   Hashtable   values;
+    private   Hashtable<String, Object>   values;
     /**
      * The value of the id attribute of this tag; or null.
      */
index 9707c1c..31c6104 100644 (file)
@@ -44,6 +44,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
     private Hashtable tagFileMap;
 
     private ParserController pc;
+    private PageInfo pi;
     private Vector vec;
 
     /**
@@ -51,11 +52,13 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
      */
     public ImplicitTagLibraryInfo(JspCompilationContext ctxt,
                                  ParserController pc,
+                  PageInfo pi,
                                  String prefix,
                                  String tagdir,
                                  ErrorDispatcher err) throws JasperException {
         super(prefix, null);
        this.pc = pc;
+    this.pi = pi;
        this.tagFileMap = new Hashtable();
        this.vec = new Vector();
 
@@ -138,4 +141,10 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
 
        return tagFile;
     }
+    
+    public TagLibraryInfo[] getTagLibraryInfos() {
+        Collection coll = pi.getTaglibs();
+        return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
+    }
+    
 }
index ce88fa3..26bec82 100644 (file)
@@ -1232,6 +1232,7 @@ class JspDocumentParser
                 new ImplicitTagLibraryInfo(
                     ctxt,
                     parserController,
+                    pageInfo,
                     prefix,
                     tagdir,
                     err);
@@ -1261,6 +1262,7 @@ class JspDocumentParser
                         new TagLibraryInfoImpl(
                             ctxt,
                             parserController,
+                            pageInfo,
                             prefix,
                             uri,
                             location,
index 97fda85..fb4d882 100644 (file)
@@ -415,7 +415,7 @@ class Parser implements TagConstants {
                     }
                     if (impl == null) {
                         String[] location = ctxt.getTldLocation(uri);
-                        impl = new TagLibraryInfoImpl(ctxt, parserController,
+                        impl = new TagLibraryInfoImpl(ctxt, parserController, pageInfo,
                                 prefix, uri, location, err);
                         if (ctxt.getOptions().isCaching()) {
                             ctxt.getOptions().getCache().put(uri, impl);
@@ -431,7 +431,7 @@ class Parser implements TagConstants {
                     if (pageInfo.getTaglib(urnTagdir) == null) {
                         pageInfo.addTaglib(urnTagdir,
                                 new ImplicitTagLibraryInfo(ctxt,
-                                        parserController, prefix, tagdir, err));
+                                        parserController, pageInfo, prefix, tagdir, err));
                     }
                     pageInfo.addPrefixMapping(prefix, urnTagdir);
                 }
index 8d67449..fe6c4b9 100644 (file)
@@ -23,6 +23,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.JarURLConnection;
 import java.net.URL;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -67,6 +68,8 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
     private Hashtable jarEntries;
 
     private JspCompilationContext ctxt;
+    
+    private PageInfo pi;
 
     private ErrorDispatcher err;
 
@@ -128,13 +131,14 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
     /**
      * Constructor.
      */
-    public TagLibraryInfoImpl(JspCompilationContext ctxt, ParserController pc,
+    public TagLibraryInfoImpl(JspCompilationContext ctxt, ParserController pc, PageInfo pi,
             String prefix, String uriIn, String[] location, ErrorDispatcher err)
             throws JasperException {
         super(prefix, uriIn);
 
         this.ctxt = ctxt;
         this.parserController = pc;
+        this.pi = pi;
         this.err = err;
         InputStream in = null;
         JarFile jarFile = null;
@@ -197,6 +201,11 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
 
     }
 
+    public TagLibraryInfo[] getTagLibraryInfos() {
+        Collection coll = pi.getTaglibs();
+        return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
+    }
+    
     /*
      * @param ctxt The JSP compilation context @param uri The TLD's uri @param
      * in The TLD's input stream @param jarFileUrl The JAR file containing the
index ca0a4b9..ce2435e 100644 (file)
@@ -220,7 +220,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver {
                }
        }
 
-       public Enumeration getAttributeNamesInScope(int scope) {
+       public Enumeration<String> getAttributeNamesInScope(int scope) {
                if (scope == PAGE_SCOPE) {
                        return pageAttributes.keys();
                }
index 0a3baa3..5008c1a 100644 (file)
@@ -491,7 +491,7 @@ public class PageContextImpl extends PageContext {
                return context.getAttribute(name);
        }
 
-       public Enumeration getAttributeNamesInScope(final int scope) {
+       public Enumeration<String> getAttributeNamesInScope(final int scope) {
                if (SecurityUtil.isPackageProtectionEnabled()) {
                        return (Enumeration) AccessController
                                        .doPrivileged(new PrivilegedAction() {