Committing Dave Brosius' patch in XALANJ-2284 that uses
get/add/remove rather than elementAt/addElement/removeElement
moving us from 1.1.x APIs on a java.util.Vector to
similar on a java.util.AbstractList.
The only point of this patch is that in the future we might
experiment with different kinds of Lists and not be stuck
with a Vector.
diff --git a/src/org/apache/xalan/lib/ExsltSets.java b/src/org/apache/xalan/lib/ExsltSets.java
index 6fca386..77e8eab 100644
--- a/src/org/apache/xalan/lib/ExsltSets.java
+++ b/src/org/apache/xalan/lib/ExsltSets.java
@@ -20,7 +20,8 @@
*/
package org.apache.xalan.lib;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.xml.utils.DOMHelper;
import org.apache.xpath.NodeSet;
@@ -190,7 +191,7 @@
NodeSet dist = new NodeSet();
dist.setShouldCacheNodes(true);
- Hashtable stringTable = new Hashtable();
+ Map stringTable = new HashMap();
for (int i = 0; i < nl.getLength(); i++)
{
diff --git a/src/org/apache/xalan/processor/ProcessorKey.java b/src/org/apache/xalan/processor/ProcessorKey.java
index e8bec0e..602649c 100644
--- a/src/org/apache/xalan/processor/ProcessorKey.java
+++ b/src/org/apache/xalan/processor/ProcessorKey.java
@@ -20,12 +20,12 @@
*/
package org.apache.xalan.processor;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.templates.KeyDeclaration;
-
import org.xml.sax.Attributes;
/**
@@ -93,7 +93,7 @@
// Keep track of which XSLTAttributeDefs have been processed, so
// I can see which default values need to be set.
- Vector processedDefs = new Vector();
+ List processedDefs = new ArrayList();
int nAttrs = attributes.getLength();
for (int i = 0; i < nAttrs; i++)
@@ -120,7 +120,7 @@
XSLMessages.createMessage(
XSLTErrorResources.ER_INVALID_KEY_CALL, null), null);
- processedDefs.addElement(attrDef);
+ processedDefs.add(attrDef);
attrDef.setAttrValue(handler, attrUri, attrLocalName,
attributes.getQName(i), attributes.getValue(i),
target);
diff --git a/src/org/apache/xalan/processor/XSLTElementProcessor.java b/src/org/apache/xalan/processor/XSLTElementProcessor.java
index 2312b81..47516ee 100644
--- a/src/org/apache/xalan/processor/XSLTElementProcessor.java
+++ b/src/org/apache/xalan/processor/XSLTElementProcessor.java
@@ -20,13 +20,16 @@
*/
package org.apache.xalan.processor;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
+import javax.xml.transform.TransformerException;
+
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.templates.ElemTemplateElement;
import org.apache.xml.utils.IntStack;
-
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.AttributesImpl;
@@ -296,10 +299,10 @@
// Keep track of which XSLTAttributeDefs have been processed, so
// I can see which default values need to be set.
- Vector processedDefs = new Vector();
+ List processedDefs = new ArrayList();
// Keep track of XSLTAttributeDefs that were invalid
- Vector errorDefs = new Vector();
+ List errorDefs = new ArrayList();
int nAttrs = attributes.getLength();
for (int i = 0; i < nAttrs; i++)
@@ -343,9 +346,9 @@
// Now we only add the element if it passed a validation check
if (success)
- processedDefs.addElement(attrDef);
+ processedDefs.add(attrDef);
else
- errorDefs.addElement(attrDef);
+ errorDefs.add(attrDef);
}
}
diff --git a/src/org/apache/xalan/xsltc/compiler/Choose.java b/src/org/apache/xalan/xsltc/compiler/Choose.java
index cad0b6d..95d3e24 100644
--- a/src/org/apache/xalan/xsltc/compiler/Choose.java
+++ b/src/org/apache/xalan/xsltc/compiler/Choose.java
@@ -21,7 +21,10 @@
package org.apache.xalan.xsltc.compiler;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
import java.util.Vector;
import org.apache.bcel.generic.BranchHandle;
@@ -58,7 +61,7 @@
* <xsl:when> elements and default to the <xsl:otherwise> if present.
*/
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
- final Vector whenElements = new Vector();
+ final List whenElements = new ArrayList();
Otherwise otherwise = null;
Enumeration elements = elements();
@@ -71,7 +74,7 @@
Object element = elements.nextElement();
// Add a When child element
if (element instanceof When) {
- whenElements.addElement(element);
+ whenElements.add(element);
}
// Add an Otherwise child element
else if (element instanceof Otherwise) {
@@ -105,12 +108,12 @@
// next element will hold a handle to the beginning of next
// When/Otherwise if test on current When fails
BranchHandle nextElement = null;
- Vector exitHandles = new Vector();
+ List exitHandles = new ArrayList();
InstructionHandle exit = null;
- Enumeration whens = whenElements.elements();
- while (whens.hasMoreElements()) {
- final When when = (When)whens.nextElement();
+ Iterator whens = whenElements.iterator();
+ while (whens.hasNext()) {
+ final When when = (When)whens.next();
final Expression test = when.getTest();
InstructionHandle truec = il.getEnd();
@@ -139,8 +142,8 @@
if (!when.ignore()) when.translateContents(classGen, methodGen);
// goto exit after executing the body of when
- exitHandles.addElement(il.append(new GOTO(null)));
- if (whens.hasMoreElements() || otherwise != null) {
+ exitHandles.add(il.append(new GOTO(null)));
+ if (whens.hasNext() || otherwise != null) {
nextElement = il.append(new GOTO(null));
test.backPatchFalseList(nextElement);
}
@@ -157,9 +160,9 @@
}
// now that end is known set targets of exit gotos
- Enumeration exitGotos = exitHandles.elements();
- while (exitGotos.hasMoreElements()) {
- BranchHandle gotoExit = (BranchHandle)exitGotos.nextElement();
+ Iterator exitGotos = exitHandles.iterator();
+ while (exitGotos.hasNext()) {
+ BranchHandle gotoExit = (BranchHandle)exitGotos.next();
gotoExit.setTarget(exit);
}
}
diff --git a/src/org/apache/xalan/xsltc/trax/DOM2SAX.java b/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
index d66c683..3e01598 100644
--- a/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
+++ b/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
@@ -23,13 +23,14 @@
package org.apache.xalan.xsltc.trax;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import java.util.Stack;
-import java.util.Vector;
+import org.apache.xalan.xsltc.dom.SAXImpl;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
@@ -42,7 +43,6 @@
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
-import org.apache.xalan.xsltc.dom.SAXImpl;
/**
* @author G. Todd Miller
@@ -217,7 +217,7 @@
case Node.ELEMENT_NODE:
String prefix;
- Vector pushedPrefixes = new Vector();
+ List pushedPrefixes = new ArrayList();
final AttributesImpl attrs = new AttributesImpl();
final NamedNodeMap map = node.getAttributes();
final int length = map.getLength();
@@ -233,7 +233,7 @@
final int colon = qnameAttr.lastIndexOf(':');
prefix = (colon > 0) ? qnameAttr.substring(colon + 1) : EMPTYSTRING;
if (startPrefixMapping(prefix, uriAttr)) {
- pushedPrefixes.addElement(prefix);
+ pushedPrefixes.add(prefix);
}
}
}
@@ -253,7 +253,7 @@
final int colon = qnameAttr.lastIndexOf(':');
prefix = (colon > 0) ? qnameAttr.substring(0, colon) : EMPTYSTRING;
if (startPrefixMapping(prefix, uriAttr)) {
- pushedPrefixes.addElement(prefix);
+ pushedPrefixes.add(prefix);
}
}
@@ -273,7 +273,7 @@
final int colon = qname.lastIndexOf(':');
prefix = (colon > 0) ? qname.substring(0, colon) : EMPTYSTRING;
if (startPrefixMapping(prefix, uri)) {
- pushedPrefixes.addElement(prefix);
+ pushedPrefixes.add(prefix);
}
}
@@ -298,7 +298,7 @@
// Generate endPrefixMapping() for all pushed prefixes
final int nPushedPrefixes = pushedPrefixes.size();
for (int i = 0; i < nPushedPrefixes; i++) {
- endPrefixMapping((String) pushedPrefixes.elementAt(i));
+ endPrefixMapping((String) pushedPrefixes.get(i));
}
break;
diff --git a/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java b/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
index 72a9009..868dfef 100644
--- a/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
+++ b/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
@@ -29,18 +29,18 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Properties;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.xml.XMLConstants;
-import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.ParserConfigurationException;
-
+import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
@@ -58,15 +58,12 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import org.apache.xml.utils.StylesheetPIHandler;
-import org.apache.xml.utils.StopParseException;
-
import org.apache.xalan.xsltc.compiler.SourceLoader;
import org.apache.xalan.xsltc.compiler.XSLTC;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
import org.apache.xalan.xsltc.dom.XSLTCDTMManager;
-
-
+import org.apache.xml.utils.StopParseException;
+import org.apache.xml.utils.StylesheetPIHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
@@ -1139,7 +1136,7 @@
}
// Load the translet into a bytecode array.
- Vector bytecodes = new Vector();
+ List bytecodes = new ArrayList();
int fileLength = (int)transletFile.length();
if (fileLength > 0) {
FileInputStream input = null;
@@ -1159,7 +1156,7 @@
return null;
}
- bytecodes.addElement(bytes);
+ bytecodes.add(bytes);
}
else
return null;
@@ -1204,7 +1201,7 @@
continue;
}
- bytecodes.addElement(bytes);
+ bytecodes.add(bytes);
}
}
@@ -1213,7 +1210,7 @@
if ( count > 0) {
final byte[][] result = new byte[count][1];
for (int i = 0; i < count; i++) {
- result[i] = (byte[])bytecodes.elementAt(i);
+ result[i] = (byte[])bytecodes.get(i);
}
return result;
@@ -1274,7 +1271,7 @@
String transletAuxPrefix = transletPath + "$";
String transletFullName = transletPath + ".class";
- Vector bytecodes = new Vector();
+ List bytecodes = new ArrayList();
// Iterate through all entries in the jar file to find the
// translet and auxiliary classes.
@@ -1294,7 +1291,7 @@
byte[] bytes = new byte[size];
readFromInputStream(bytes, input, size);
input.close();
- bytecodes.addElement(bytes);
+ bytecodes.add(bytes);
}
catch (IOException e) {
return null;
@@ -1307,7 +1304,7 @@
if (count > 0) {
final byte[][] result = new byte[count][1];
for (int i = 0; i < count; i++) {
- result[i] = (byte[])bytecodes.elementAt(i);
+ result[i] = (byte[])bytecodes.get(i);
}
return result;
diff --git a/src/org/apache/xml/serializer/Encodings.java b/src/org/apache/xml/serializer/Encodings.java
index f3db4b9..6b051f1 100644
--- a/src/org/apache/xml/serializer/Encodings.java
+++ b/src/org/apache/xml/serializer/Encodings.java
@@ -25,11 +25,12 @@
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.Vector;
/**
@@ -313,7 +314,7 @@
int totalEntries = props.size();
- Vector encodingInfo_list = new Vector();
+ List encodingInfo_list = new ArrayList();
Enumeration keys = props.keys();
for (int i = 0; i < totalEntries; ++i)
{
diff --git a/src/org/apache/xml/utils/Hashtree2Node.java b/src/org/apache/xml/utils/Hashtree2Node.java
index fc9de53..49e3fd3 100644
--- a/src/org/apache/xml/utils/Hashtree2Node.java
+++ b/src/org/apache/xml/utils/Hashtree2Node.java
@@ -21,9 +21,11 @@
package org.apache.xml.utils;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.Vector;
+import java.util.Iterator;
+import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -84,7 +86,7 @@
container.appendChild(hashNode);
Enumeration keys = hash.keys();
- Vector v = new Vector();
+ List v = new ArrayList();
while (keys.hasMoreElements())
{
@@ -97,8 +99,8 @@
// Ensure a pre-order traversal; add this hashes
// items before recursing to child hashes
// Save name and hash in two steps
- v.addElement(keyStr);
- v.addElement((Hashtable) item);
+ v.add(keyStr);
+ v.add((Hashtable) item);
}
else
{
@@ -121,12 +123,12 @@
}
// Now go back and do the saved hashes
- keys = v.elements();
- while (keys.hasMoreElements())
+ Iterator it = v.iterator();
+ while (it.hasNext())
{
// Retrieve name and hash in two steps
- String n = (String) keys.nextElement();
- Hashtable h = (Hashtable) keys.nextElement();
+ String n = (String) it.next();
+ Hashtable h = (Hashtable) it.next();
appendHashToNode(h, n, hashNode, factory);
}