From: remm Date: Wed, 20 Sep 2006 01:18:29 +0000 (+0000) Subject: - Similar change. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=29de2627e7f5e1be89ad9f4b653531897fc1f378;p=tomcat7.0 - Similar change. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@448023 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/runtime/JspContextWrapper.java b/java/org/apache/jasper/runtime/JspContextWrapper.java index c7cd7ab6f..a42fb4e05 100644 --- a/java/org/apache/jasper/runtime/JspContextWrapper.java +++ b/java/org/apache/jasper/runtime/JspContextWrapper.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Enumeration; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -42,6 +42,7 @@ import javax.servlet.jsp.tagext.BodyContent; import javax.servlet.jsp.tagext.VariableInfo; import org.apache.jasper.compiler.Localizer; +import org.apache.jasper.util.Enumerator; /** * Implementation of a JSP Context Wrapper. @@ -60,7 +61,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { // Invoking JSP context private PageContext invokingJspCtxt; - private transient Hashtable pageAttributes; + private transient HashMap pageAttributes; // ArrayList of NESTED scripting variables private ArrayList nestedVars; @@ -73,7 +74,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { private Map aliases; - private Hashtable originalNestedVars; + private HashMap originalNestedVars; public JspContextWrapper(JspContext jspContext, ArrayList nestedVars, ArrayList atBeginVars, ArrayList atEndVars, Map aliases) { @@ -81,11 +82,11 @@ public class JspContextWrapper extends PageContext implements VariableResolver { this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; this.atEndVars = atEndVars; - this.pageAttributes = new Hashtable(16); + this.pageAttributes = new HashMap(16); this.aliases = aliases; if (nestedVars != null) { - this.originalNestedVars = new Hashtable(nestedVars.size()); + this.originalNestedVars = new HashMap(nestedVars.size()); } syncBeginTagFile(); } @@ -220,7 +221,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { public Enumeration getAttributeNamesInScope(int scope) { if (scope == PAGE_SCOPE) { - return pageAttributes.keys(); + return new Enumerator(pageAttributes.keySet().iterator()); } return invokingJspCtxt.getAttributeNamesInScope(scope); diff --git a/java/org/apache/jasper/util/Enumerator.java b/java/org/apache/jasper/util/Enumerator.java new file mode 100644 index 000000000..ba79b2882 --- /dev/null +++ b/java/org/apache/jasper/util/Enumerator.java @@ -0,0 +1,175 @@ +/* + * Copyright 1999,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.jasper.util; + + +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.NoSuchElementException; + + +/** + * Adapter class that wraps an Enumeration around a Java2 + * collection classes object Iterator so that existing APIs + * returning Enumerations can easily run on top of the new collections. + * Constructors are provided to easliy create such wrappers. + * + * @author Craig R. McClanahan + * @version $Revision: 302726 $ $Date: 2004-02-27 15:59:07 +0100 (ven., 27 févr. 2004) $ + */ + +public final class Enumerator implements Enumeration { + + + // ----------------------------------------------------------- Constructors + + + /** + * Return an Enumeration over the values of the specified Collection. + * + * @param collection Collection whose values should be enumerated + */ + public Enumerator(Collection collection) { + + this(collection.iterator()); + + } + + + /** + * Return an Enumeration over the values of the specified Collection. + * + * @param collection Collection whose values should be enumerated + * @param clone true to clone iterator + */ + public Enumerator(Collection collection, boolean clone) { + + this(collection.iterator(), clone); + + } + + + /** + * Return an Enumeration over the values returned by the + * specified Iterator. + * + * @param iterator Iterator to be wrapped + */ + public Enumerator(Iterator iterator) { + + super(); + this.iterator = iterator; + + } + + + /** + * Return an Enumeration over the values returned by the + * specified Iterator. + * + * @param iterator Iterator to be wrapped + * @param clone true to clone iterator + */ + public Enumerator(Iterator iterator, boolean clone) { + + super(); + if (!clone) { + this.iterator = iterator; + } else { + List list = new ArrayList(); + while (iterator.hasNext()) { + list.add(iterator.next()); + } + this.iterator = list.iterator(); + } + + } + + + /** + * Return an Enumeration over the values of the specified Map. + * + * @param map Map whose values should be enumerated + */ + public Enumerator(Map map) { + + this(map.values().iterator()); + + } + + + /** + * Return an Enumeration over the values of the specified Map. + * + * @param map Map whose values should be enumerated + * @param clone true to clone iterator + */ + public Enumerator(Map map, boolean clone) { + + this(map.values().iterator(), clone); + + } + + + // ----------------------------------------------------- Instance Variables + + + /** + * The Iterator over which the Enumeration + * represented by this class actually operates. + */ + private Iterator iterator = null; + + + // --------------------------------------------------------- Public Methods + + + /** + * Tests if this enumeration contains more elements. + * + * @return true if and only if this enumeration object + * contains at least one more element to provide, false + * otherwise + */ + public boolean hasMoreElements() { + + return (iterator.hasNext()); + + } + + + /** + * Returns the next element of this enumeration if this enumeration + * has at least one more element to provide. + * + * @return the next element of this enumeration + * + * @exception NoSuchElementException if no more elements exist + */ + public Object nextElement() throws NoSuchElementException { + + return (iterator.next()); + + } + + +}