You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/03/26 00:50:18 UTC

svn commit: r388860 - in /xerces/java/trunk/src/org/apache/xerces: dom/ impl/dtd/models/ impl/xpath/ impl/xs/ impl/xs/models/ impl/xs/opti/ impl/xs/util/

Author: mrglavas
Date: Sat Mar 25 15:50:16 2006
New Revision: 388860

URL: http://svn.apache.org/viewcvs?rev=388860&view=rev
Log:
JIRA Issue #1148:
http://issues.apache.org/jira/browse/XERCESJ-1148

Use non-synchronized collections where possible. Patch thanks to Dave Brosius.

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/DocumentImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/RangeImpl.java
    xerces/java/trunk/src/org/apache/xerces/impl/dtd/models/DFAContentModel.java
    xerces/java/trunk/src/org/apache/xerces/impl/xpath/XPath.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/DocumentImpl.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DocumentImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DocumentImpl.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001,2002,2004,2005 The Apache Software Foundation.
+ * Copyright 2001,2002,2004-2006 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.
@@ -17,12 +17,12 @@
 package org.apache.xerces.dom;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Vector;
 
 import org.apache.xerces.dom.events.EventImpl;
 import org.apache.xerces.dom.events.MutationEventImpl;
-import org.w3c.dom.UserDataHandler;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
@@ -30,6 +30,7 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.UserDataHandler;
 import org.w3c.dom.events.DocumentEvent;
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventException;
@@ -687,11 +688,11 @@
         // is issued to the Element rather than the Attr
         // and causes a _second_ DOMSubtreeModified in the Element's
         // tree.
-        Vector pv = new Vector(10,10);
+        ArrayList pv = new ArrayList(10);
         Node p = node;
         Node n = p.getParentNode();
         while (n != null) {
-            pv.addElement(n);
+            pv.add(n);
             p = n;
             n = n.getParentNode();
         }
@@ -706,7 +707,7 @@
                     break;  // Someone set the flag. Phase ends.
 
                 // Handle all capturing listeners on this node
-                NodeImpl nn = (NodeImpl) pv.elementAt(j);
+                NodeImpl nn = (NodeImpl) pv.get(j);
                 evt.currentTarget = nn;
                 Vector nodeListeners = getEventListeners(nn);
                 if (nodeListeners != null) {
@@ -768,7 +769,7 @@
                         break;  // Someone set the flag. Phase ends.
 
                     // Handle all bubbling listeners on this node
-                    NodeImpl nn = (NodeImpl) pv.elementAt(j);
+                    NodeImpl nn = (NodeImpl) pv.get(j);
                     evt.currentTarget = nn;
                     nodeListeners = getEventListeners(nn);
                     if (nodeListeners != null) {

Modified: xerces/java/trunk/src/org/apache/xerces/dom/RangeImpl.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/RangeImpl.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/RangeImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/RangeImpl.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 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.
@@ -16,7 +16,7 @@
 
 package org.apache.xerces.dom;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 import org.w3c.dom.CharacterData;
 import org.w3c.dom.DOMException;
@@ -123,25 +123,25 @@
                 DOMException.INVALID_STATE_ERR, 
                 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
         }
-        Vector startV = new Vector();
+        ArrayList startV = new ArrayList();
         Node node;
         for (node=fStartContainer; node != null; 
              node=node.getParentNode()) 
         {
-            startV.addElement(node);
+            startV.add(node);
         }
-        Vector endV = new Vector();
+        ArrayList endV = new ArrayList();
         for (node=fEndContainer; node != null; 
              node=node.getParentNode()) 
         {
-            endV.addElement(node);
+            endV.add(node);
         }
         int s = startV.size()-1;
         int e = endV.size()-1;
         Object result = null;
         while (s>=0 && e>=0) {
-            if (startV.elementAt(s) == endV.elementAt(e)) {
-                result = startV.elementAt(s);
+            if (startV.get(s) == endV.get(e)) {
+                result = startV.get(s);
             } else {
                 break;
             }

Modified: xerces/java/trunk/src/org/apache/xerces/impl/dtd/models/DFAContentModel.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/dtd/models/DFAContentModel.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/dtd/models/DFAContentModel.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/dtd/models/DFAContentModel.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004,2006 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.
@@ -16,8 +16,10 @@
 
 package org.apache.xerces.impl.dtd.models;
 
-import org.apache.xerces.xni.QName;
+import java.util.HashMap;
+
 import org.apache.xerces.impl.dtd.XMLContentSpec;
+import org.apache.xerces.xni.QName;
 
 /**
  * DFAContentModel is the derivative of ContentModel that does
@@ -588,7 +590,7 @@
 	     * a large content model such as, "(t001+|t002+|.... |t500+)".
 	     */
 
-	java.util.Hashtable stateTable = new java.util.Hashtable();
+        HashMap stateTable = new HashMap();
 
 	    /* Optimization(Jan, 2001) */
 

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xpath/XPath.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xpath/XPath.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xpath/XPath.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xpath/XPath.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2002,2004,2005 The Apache Software Foundation.
+ * Copyright 2000-2002,2004-2006 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.
@@ -16,11 +16,12 @@
 
 package org.apache.xerces.impl.xpath;
 
+import java.util.ArrayList;
 import java.util.Vector;
 
 import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.util.XMLChar;
+import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.xni.NamespaceContext;
 import org.apache.xerces.xni.QName;
 
@@ -178,7 +179,7 @@
         
         //fTokens.dumpTokens();
         Vector stepsVector = new Vector();
-        Vector locationPathsVector= new Vector();
+        ArrayList locationPathsVector= new ArrayList();
         
         // true when the next token should be 'Step' (as defined in
         // the production rule [3] of XML Schema P1 section 3.11.6
@@ -194,7 +195,7 @@
             switch (token) {
                 case  XPath.Tokens.EXPRTOKEN_OPERATOR_UNION :{
                     check(!expectingStep);
-                    locationPathsVector.addElement(buildLocationPath(stepsVector));
+                    locationPathsVector.add(buildLocationPath(stepsVector));
                     expectingStep=true;
                     break;
                 }
@@ -271,11 +272,10 @@
         
         check(!expectingStep);
 
-        locationPathsVector.addElement(buildLocationPath(stepsVector));
+        locationPathsVector.add(buildLocationPath(stepsVector));
 
         // save location path
-        fLocationPaths=new LocationPath[locationPathsVector.size()];
-        locationPathsVector.copyInto(fLocationPaths);
+        fLocationPaths = (LocationPath[])locationPathsVector.toArray(new LocationPath[locationPathsVector.size()]);
 
 
         if (DEBUG_XPATH_PARSE) {

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2005 The Apache Software Foundation.
+ * Copyright 2000-2006 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.
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Locale;
 import java.util.StringTokenizer;
@@ -64,8 +65,8 @@
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.DOMStringList;
 import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMStringList;
 import org.w3c.dom.ls.LSInput;
 import org.w3c.dom.ls.LSResourceResolver;
 import org.xml.sax.InputSource;
@@ -741,7 +742,7 @@
         // InputSource also, apart from [] of type Object.
         Object[] objArr = (Object[]) fJAXPSource;
         //make local vector for storing targetn namespaces of schemasources specified in object arrays.
-        Vector jaxpSchemaSourceNamespaces = new Vector() ;
+        ArrayList jaxpSchemaSourceNamespaces = new ArrayList();
         for (int i = 0; i < objArr.length; i++) {
             if(objArr[i] instanceof InputStream ||
                     objArr[i] instanceof InputSource) {

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 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.
@@ -16,18 +16,19 @@
 
 package org.apache.xerces.impl.xs.models;
 
-import org.apache.xerces.xni.QName;
+import java.util.HashMap;
+import java.util.Vector;
+
 import org.apache.xerces.impl.dtd.models.CMNode;
 import org.apache.xerces.impl.dtd.models.CMStateSet;
 import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
+import org.apache.xerces.impl.xs.XMLSchemaException;
+import org.apache.xerces.impl.xs.XSConstraints;
 import org.apache.xerces.impl.xs.XSElementDecl;
-import org.apache.xerces.impl.xs.XSParticleDecl;
 import org.apache.xerces.impl.xs.XSModelGroupImpl;
+import org.apache.xerces.impl.xs.XSParticleDecl;
 import org.apache.xerces.impl.xs.XSWildcardDecl;
-import org.apache.xerces.impl.xs.XMLSchemaException;
-import org.apache.xerces.impl.xs.XSConstraints;
-
-import java.util.Vector;
+import org.apache.xerces.xni.QName;
 
 /**
  * DFAContentModel is the implementation of XSCMValidator that does
@@ -508,7 +509,7 @@
          * a large content model such as, "(t001+|t002+|.... |t500+)".
          */
 
-        java.util.Hashtable stateTable = new java.util.Hashtable();
+        HashMap stateTable = new HashMap();
 
         /* Optimization(Jan, 2001) */
 

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java Sat Mar 25 15:50:16 2006
@@ -16,19 +16,19 @@
 
 package org.apache.xerces.impl.xs.opti;
 
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.xni.NamespaceContext;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
 import org.apache.xerces.xni.XMLString;
-import org.apache.xerces.util.XMLSymbols;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
-import java.util.Vector;
-import java.util.Enumeration;
-
 /**
  * @xerces.internal  
  * 
@@ -339,14 +339,14 @@
         // for other namespaces so that we can also include them.
         // optimized for simplicity and the case that not many
         // namespaces are declared on this annotation...
-        Vector namespaces = new Vector();
+        ArrayList namespaces = new ArrayList();
         for (int i = 0; i < attributes.getLength(); ++i) {
             String aValue = attributes.getValue(i);
             String aPrefix = attributes.getPrefix(i);
             String aQName = attributes.getQName(i);
             // if it's xmlns:* or xmlns, must be a namespace decl
             if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
-                namespaces.addElement(aPrefix == XMLSymbols.PREFIX_XMLNS ? 
+                namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? 
                         attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
             }
             fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java?rev=388860&r1=388859&r2=388860&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java Sat Mar 25 15:50:16 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003,2004 The Apache Software Foundation.
+ * Copyright 2003,2004,2006 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.
@@ -16,12 +16,13 @@
 
 package org.apache.xerces.impl.xs.util;
 
+import java.util.ArrayList;
+
 import org.apache.xerces.impl.xs.SchemaGrammar;
 import org.apache.xerces.impl.xs.XSModelImpl;
-import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.util.XMLGrammarPoolImpl;
 import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-
+import org.apache.xerces.xs.XSModel;
 
 /**
  * Add a method that return an <code>XSModel</code> that represents components in
@@ -39,20 +40,19 @@
      * @return  an <code>XSModel</code> representing this schema grammar
      */
     public XSModel toXSModel() {
-        java.util.Vector list = new java.util.Vector();
+        ArrayList list = new ArrayList();
         for (int i = 0; i < fGrammars.length; i++) {
             for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) {
                 if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA))
-                    list.addElement(entry.grammar);
+                    list.add(entry.grammar);
             }
         }
 
         int size = list.size();
-        if (size == 0)
+        if (size == 0) {
             return null;
-        SchemaGrammar[] gs = new SchemaGrammar[size];
-        for (int i = 0; i < size; i++)
-            gs[i] = (SchemaGrammar)list.elementAt(i);
+        }
+        SchemaGrammar[] gs = (SchemaGrammar[])list.toArray(new SchemaGrammar[size]);
         return new XSModelImpl(gs);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org