You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2006/09/20 03:18:30 UTC
svn commit: r448023 - in /tomcat/tc6.0.x/trunk/java/org/apache/jasper:
runtime/JspContextWrapper.java util/Enumerator.java
Author: remm
Date: Tue Sep 19 18:18:29 2006
New Revision: 448023
URL: http://svn.apache.org/viewvc?view=rev&rev=448023
Log:
- Similar change.
Added:
tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java (with props)
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java?view=diff&rev=448023&r1=448022&r2=448023
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java Tue Sep 19 18:18:29 2006
@@ -20,7 +20,7 @@
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.VariableInfo;
import org.apache.jasper.compiler.Localizer;
+import org.apache.jasper.util.Enumerator;
/**
* Implementation of a JSP Context Wrapper.
@@ -60,7 +61,7 @@
// Invoking JSP context
private PageContext invokingJspCtxt;
- private transient Hashtable pageAttributes;
+ private transient HashMap<String, Object> pageAttributes;
// ArrayList of NESTED scripting variables
private ArrayList nestedVars;
@@ -73,7 +74,7 @@
private Map aliases;
- private Hashtable originalNestedVars;
+ private HashMap<String, Object> originalNestedVars;
public JspContextWrapper(JspContext jspContext, ArrayList nestedVars,
ArrayList atBeginVars, ArrayList atEndVars, Map aliases) {
@@ -81,11 +82,11 @@
this.nestedVars = nestedVars;
this.atBeginVars = atBeginVars;
this.atEndVars = atEndVars;
- this.pageAttributes = new Hashtable(16);
+ this.pageAttributes = new HashMap<String, Object>(16);
this.aliases = aliases;
if (nestedVars != null) {
- this.originalNestedVars = new Hashtable(nestedVars.size());
+ this.originalNestedVars = new HashMap<String, Object>(nestedVars.size());
}
syncBeginTagFile();
}
@@ -220,7 +221,7 @@
public Enumeration<String> getAttributeNamesInScope(int scope) {
if (scope == PAGE_SCOPE) {
- return pageAttributes.keys();
+ return new Enumerator(pageAttributes.keySet().iterator());
}
return invokingJspCtxt.getAttributeNamesInScope(scope);
Added: tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java?view=auto&rev=448023
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java Tue Sep 19 18:18:29 2006
@@ -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 <code>Enumeration</code> around a Java2
+ * collection classes object <code>Iterator</code> 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 <code>Iterator</code> over which the <code>Enumeration</code>
+ * represented by this class actually operates.
+ */
+ private Iterator iterator = null;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Tests if this enumeration contains more elements.
+ *
+ * @return <code>true</code> if and only if this enumeration object
+ * contains at least one more element to provide, <code>false</code>
+ * 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());
+
+ }
+
+
+}
Propchange: tomcat/tc6.0.x/trunk/java/org/apache/jasper/util/Enumerator.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org