Author: knoaman
Date: Mon Nov 23 20:32:14 2009
New Revision: 883491
URL: http://svn.apache.org/viewvc?rev=883491&view=rev
Log:
Use ArrayList and HashMap instead of Vector and HashTable - Keep 1.1 branch up
to date with Xerces-J trunk
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/DTDGrammar.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/DTDGrammar.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/DTDGrammar.java?rev=883491&r1=883490&r2=883491&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/DTDGrammar.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/DTDGrammar.java
Mon Nov 23 20:32:14 2009
@@ -17,8 +17,8 @@
package org.apache.xerces.impl.dtd;
+import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.Vector;
import org.apache.xerces.impl.dtd.models.CMAny;
import org.apache.xerces.impl.dtd.models.CMBinOp;
@@ -790,16 +790,17 @@
public void endDTD(Augmentations augs) throws XNIException {
fIsImmutable = true;
// make sure our description contains useful stuff...
- if(fGrammarDescription.getRootName() == null) {
+ if (fGrammarDescription.getRootName() == null) {
// we don't know what the root is; so use possibleRoots...
int chunk, index = 0;
String currName = null;
- Vector elements = new Vector();
- for (int i=0; i < fElementDeclCount; i++) {
+ final int size = fElementDeclCount;
+ ArrayList elements = new ArrayList(size);
+ for (int i = 0; i < size; ++i) {
chunk = i >> CHUNK_SHIFT;
index = i & CHUNK_MASK;
currName = fElementDeclName[chunk][index].rawname;
- elements.addElement(currName);
+ elements.add(currName);
}
fGrammarDescription.setPossibleRoots(elements);
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java?rev=883491&r1=883490&r2=883491&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java
Mon Nov 23 20:32:14 2009
@@ -17,6 +17,7 @@
package org.apache.xerces.impl.dtd;
+import java.util.ArrayList;
import java.util.Vector;
import org.apache.xerces.util.XMLResourceIdentifierImpl;
@@ -43,7 +44,7 @@
// if we don't know the root name, this stores all elements that
// could serve; fPossibleRoots and fRootName cannot both be non-null
- protected Vector fPossibleRoots = null;
+ protected ArrayList fPossibleRoots = null;
// Constructors:
public XMLDTDDescription(XMLResourceIdentifier id, String rootName) {
@@ -85,11 +86,16 @@
fRootName = rootName;
fPossibleRoots = null;
}
+
+ /** Set possible roots **/
+ public void setPossibleRoots(ArrayList possibleRoots) {
+ fPossibleRoots = possibleRoots;
+ }
/** Set possible roots **/
public void setPossibleRoots(Vector possibleRoots) {
- fPossibleRoots = possibleRoots;
- }
+ fPossibleRoots = (possibleRoots != null) ? new
ArrayList(possibleRoots) : null;
+ }
/**
* Compares this grammar with the given grammar. Currently, we compare
@@ -105,49 +111,58 @@
* @return True if they are equal, else false
*/
public boolean equals(Object desc) {
- if(!(desc instanceof XMLGrammarDescription)) return false;
+ if (!(desc instanceof XMLGrammarDescription)) return false;
if
(!getGrammarType().equals(((XMLGrammarDescription)desc).getGrammarType())) {
return false;
}
// assume it's a DTDDescription
XMLDTDDescription dtdDesc = (XMLDTDDescription)desc;
- if(fRootName != null) {
- if((dtdDesc.fRootName) != null &&
!dtdDesc.fRootName.equals(fRootName)) {
+ if (fRootName != null) {
+ if ((dtdDesc.fRootName) != null &&
!dtdDesc.fRootName.equals(fRootName)) {
return false;
- } else if(dtdDesc.fPossibleRoots != null &&
!dtdDesc.fPossibleRoots.contains(fRootName)) {
+ }
+ else if (dtdDesc.fPossibleRoots != null &&
!dtdDesc.fPossibleRoots.contains(fRootName)) {
return false;
}
- } else if(fPossibleRoots != null) {
- if(dtdDesc.fRootName != null) {
- if(!fPossibleRoots.contains(dtdDesc.fRootName)) {
+ }
+ else if (fPossibleRoots != null) {
+ if (dtdDesc.fRootName != null) {
+ if (!fPossibleRoots.contains(dtdDesc.fRootName)) {
return false;
}
- } else if(dtdDesc.fPossibleRoots == null) {
+ }
+ else if (dtdDesc.fPossibleRoots == null) {
return false;
- } else {
+ }
+ else {
boolean found = false;
- for(int i = 0; i<fPossibleRoots.size(); i++) {
- String root = (String)fPossibleRoots.elementAt(i);
+ final int size = fPossibleRoots.size();
+ for (int i = 0; i < size; ++i) {
+ String root = (String) fPossibleRoots.get(i);
found = dtdDesc.fPossibleRoots.contains(root);
- if(found) break;
+ if (found) break;
}
- if(!found) return false;
+ if (!found) return false;
}
}
// if we got this far we've got a root match... try other two fields,
// since so many different DTD's have roots in common:
- if(fExpandedSystemId != null) {
- if(!fExpandedSystemId.equals(dtdDesc.fExpandedSystemId))
+ if (fExpandedSystemId != null) {
+ if (!fExpandedSystemId.equals(dtdDesc.fExpandedSystemId)) {
return false;
+ }
}
- else if(dtdDesc.fExpandedSystemId != null)
+ else if (dtdDesc.fExpandedSystemId != null) {
return false;
- if(fPublicId != null) {
- if(!fPublicId.equals(dtdDesc.fPublicId))
+ }
+ if (fPublicId != null) {
+ if (!fPublicId.equals(dtdDesc.fPublicId)) {
return false;
+ }
}
- else if(dtdDesc.fPublicId != null)
+ else if (dtdDesc.fPublicId != null) {
return false;
+ }
return true;
}
@@ -158,10 +173,12 @@
* @return The hash code
*/
public int hashCode() {
- if(fExpandedSystemId != null)
+ if (fExpandedSystemId != null) {
return fExpandedSystemId.hashCode();
- if(fPublicId != null)
+ }
+ if (fPublicId != null) {
return fPublicId.hashCode();
+ }
// give up; hope .equals can handle it:
return 0;
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java?rev=883491&r1=883490&r2=883491&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
Mon Nov 23 20:32:14 2009
@@ -17,11 +17,12 @@
package org.apache.xerces.impl.dtd;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.Locale;
+import java.util.Map;
import java.util.StringTokenizer;
-import java.util.Vector;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
@@ -235,28 +236,28 @@
private final XMLEntityDecl fEntityDecl = new XMLEntityDecl();
/** Notation declaration hash. */
- private final Hashtable fNDataDeclNotations = new Hashtable();
+ private final HashMap fNDataDeclNotations = new HashMap();
/** DTD element declaration name. */
private String fDTDElementDeclName = null;
/** Mixed element type "hash". */
- private final Vector fMixedElementTypes = new Vector();
+ private final ArrayList fMixedElementTypes = new ArrayList();
/** Element declarations in DTD. */
- private final Vector fDTDElementDecls = new Vector();
+ private final ArrayList fDTDElementDecls = new ArrayList();
// to check for duplicate ID or ANNOTATION attribute declare in
// ATTLIST, and misc VCs
/** ID attribute names. */
- private Hashtable fTableOfIDAttributeNames;
+ private HashMap fTableOfIDAttributeNames;
/** NOTATION attribute names. */
- private Hashtable fTableOfNOTATIONAttributeNames;
+ private HashMap fTableOfNOTATIONAttributeNames;
/** NOTATION enumeration values. */
- private Hashtable fNotationEnumVals;
+ private HashMap fNotationEnumVals;
//
// Constructors
@@ -374,12 +375,12 @@
if (fValidation) {
if (fNotationEnumVals == null) {
- fNotationEnumVals = new Hashtable();
+ fNotationEnumVals = new HashMap();
}
fNotationEnumVals.clear();
- fTableOfIDAttributeNames = new Hashtable();
- fTableOfNOTATIONAttributeNames = new Hashtable();
+ fTableOfIDAttributeNames = new HashMap();
+ fTableOfNOTATIONAttributeNames = new HashMap();
}
}
@@ -652,7 +653,7 @@
// initialize state
fNDataDeclNotations.clear();
- fDTDElementDecls.removeAllElements();
+ fDTDElementDecls.clear();
// the grammar bucket's DTDGrammar will now be the
// one we want, whether we're constructing it or not.
@@ -788,7 +789,7 @@
XMLErrorReporter.SEVERITY_ERROR);
}
else {
- fDTDElementDecls.addElement(name);
+ fDTDElementDecls.add(name);
}
}
@@ -938,7 +939,7 @@
//we should not report an error, when there is
duplicate attribute definition for given element type
//according to XML 1.0 spec, When more than one
definition is provided for the same attribute of a given
//element type, the first declaration is binding and
later declaration are *ignored*. So processor should
- //ignore the second declarations, however an
application would be warned of the duplicate attribute defintion
+ //ignore the second declarations, however an
application would be warned of the duplicate attribute definition
// if
http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is
set to true, Application behavior may differ on the basis of error or
//warning thrown. - nb.
@@ -1298,11 +1299,12 @@
DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar:
fGrammarBucket.getActiveGrammar());
// VC : Notation Declared. for external entity declaration
[Production 76].
- Enumeration entities = fNDataDeclNotations.keys();
- while (entities.hasMoreElements()) {
- String entity = (String) entities.nextElement();
- String notation = (String) fNDataDeclNotations.get(entity);
+ Iterator entities = fNDataDeclNotations.entrySet().iterator();
+ while (entities.hasNext()) {
+ Map.Entry entry = (Map.Entry) entities.next();
+ String notation = (String) entry.getValue();
if (grammar.getNotationDeclIndex(notation) == -1) {
+ String entity = (String) entry.getKey();
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_NOTATION_NOT_DECLARED_FOR_UNPARSED_ENTITYDECL",
new Object[]{entity, notation},
@@ -1312,11 +1314,12 @@
// VC: Notation Attributes:
// all notation names in the (attribute) declaration must be
declared.
- Enumeration notationVals = fNotationEnumVals.keys();
- while (notationVals.hasMoreElements()) {
- String notation = (String) notationVals.nextElement();
- String attributeName = (String)
fNotationEnumVals.get(notation);
+ Iterator notationVals = fNotationEnumVals.entrySet().iterator();
+ while (notationVals.hasNext()) {
+ Map.Entry entry = (Map.Entry) notationVals.next();
+ String notation = (String) entry.getKey();
if (grammar.getNotationDeclIndex(notation) == -1) {
+ String attributeName = (String) entry.getValue();
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"MSG_NOTATION_NOT_DECLARED_FOR_NOTATIONTYPE_ATTRIBUTE",
new Object[]{attributeName,
notation},
@@ -1326,12 +1329,13 @@
// VC: No Notation on Empty Element
// An attribute of type NOTATION must not be declared on an
element declared EMPTY.
- Enumeration elementsWithNotations =
fTableOfNOTATIONAttributeNames.keys();
- while (elementsWithNotations.hasMoreElements()) {
- String elementName = (String)
elementsWithNotations.nextElement();
+ Iterator elementsWithNotations =
fTableOfNOTATIONAttributeNames.entrySet().iterator();
+ while (elementsWithNotations.hasNext()) {
+ Map.Entry entry = (Map.Entry) elementsWithNotations.next();
+ String elementName = (String) entry.getKey();
int elementIndex = grammar.getElementDeclIndex(elementName);
if (grammar.getContentSpecType(elementIndex) ==
XMLElementDecl.TYPE_EMPTY) {
- String attributeName = (String)
fTableOfNOTATIONAttributeNames.get(elementName);
+ String attributeName = (String) entry.getValue();
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"NoNotationOnEmptyElement",
new Object[]{elementName,
attributeName},
@@ -1397,7 +1401,7 @@
if (fValidation) {
fDTDElementDeclName = elementName;
- fMixedElementTypes.removeAllElements();
+ fMixedElementTypes.clear();
}
// call handlers
@@ -1514,7 +1518,7 @@
XMLErrorReporter.SEVERITY_ERROR);
}
else {
- fMixedElementTypes.addElement(elementName);
+ fMixedElementTypes.add(elementName);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]