userData;
try {
node = (NodeImpl) source;
} catch (ClassCastException e) {
@@ -1774,8 +1807,8 @@
// Return null if the source is null
if (source == null ) {
- return null;
- } else if (source != null && source.getOwnerDocument() != null) {
+ return null;
+ } else if (source.getOwnerDocument() != null) {
DOMImplementation thisImpl = this.getImplementation();
DOMImplementation otherImpl = source.getOwnerDocument().getImplementation();
@@ -1795,7 +1828,7 @@
// Adopting between two dissimilar DOM's is not allowed
return null;
}
- }
+ }
}
switch (node.getNodeType()) {
@@ -1808,12 +1841,13 @@
}
//2. specified flag is set to true
attr.isSpecified(true);
- userData = node.getUserDataRecord();
+ userData = node.getUserDataRecord();
//3. change ownership
attr.setOwnerDocument(this);
- if(userData != null )
- setUserDataTable(node,userData);
+ if (userData != null) {
+ setUserDataTable(node, userData);
+ }
break;
}
//entity, notation nodes are read only nodes.. so they can't be adopted.
@@ -1832,7 +1866,7 @@
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
case ENTITY_REFERENCE_NODE: {
- userData = node.getUserDataRecord();
+ userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
@@ -1845,8 +1879,9 @@
}
// change ownership
node.setOwnerDocument(this);
- if(userData != null)
- setUserDataTable(node,userData);
+ if (userData != null) {
+ setUserDataTable(node, userData);
+ }
// set its new replacement value if any
if (docType == null) {
break;
@@ -1857,14 +1892,14 @@
break;
}
for (child = entityNode.getFirstChild();
- child != null; child = child.getNextSibling()) {
+ child != null; child = child.getNextSibling()) {
Node childClone = child.cloneNode(true);
node.appendChild(childClone);
}
break;
}
case ELEMENT_NODE: {
- userData = node.getUserDataRecord();
+ userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
@@ -1872,14 +1907,15 @@
}
// change ownership
node.setOwnerDocument(this);
- if(userData != null)
- setUserDataTable(node,userData);
+ if (userData != null) {
+ setUserDataTable(node, userData);
+ }
// reconcile default attributes
((ElementImpl)node).reconcileDefaultAttributes();
break;
}
default: {
- userData = node.getUserDataRecord();
+ userData = node.getUserDataRecord();
// remove node from wherever it is
Node parent = node.getParentNode();
if (parent != null) {
@@ -1887,15 +1923,17 @@
}
// change ownership
node.setOwnerDocument(this);
- if(userData != null)
- setUserDataTable(node,userData);
+ if (userData != null) {
+ setUserDataTable(node, userData);
+ }
}
}
//DOM L3 Core CR
- //http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#UserDataHandler-ADOPTED
- if(userData != null)
- callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED,userData);
+ //http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#UserDataHandler-ADOPTED
+ if (userData != null) {
+ callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED, userData);
+ }
return node;
}
@@ -1994,7 +2032,7 @@
}
if (identifiers == null) {
- identifiers = new Hashtable();
+ identifiers = new HashMap<>();
}
identifiers.put(idName, element);
@@ -2052,25 +2090,9 @@
} // removeIdentifier(String)
- /** Returns an enumeration registered of identifier names. */
- public Enumeration getIdentifiers() {
-
- if (needsSyncData()) {
- synchronizeData();
- }
-
- if (identifiers == null) {
- identifiers = new Hashtable();
- }
-
- return identifiers.keys();
-
- } // getIdentifiers():Enumeration
-
//
// DOM2: Namespace methods
//
-
/**
* Introduced in DOM Level 2.
* Creates an element of the given qualified name and namespace URI.
@@ -2095,7 +2117,7 @@
* @since WD-DOM-Level-2-19990923
*/
public Element createElementNS(String namespaceURI, String qualifiedName)
- throws DOMException {
+ throws DOMException {
return new ElementNSImpl(this, namespaceURI, qualifiedName);
}
@@ -2114,8 +2136,8 @@
* name contains an invalid character.
*/
public Element createElementNS(String namespaceURI, String qualifiedName,
- String localpart)
- throws DOMException {
+ String localpart)
+ throws DOMException {
return new ElementNSImpl(this, namespaceURI, qualifiedName, localpart);
}
@@ -2138,7 +2160,7 @@
* @since WD-DOM-Level-2-19990923
*/
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
- throws DOMException {
+ throws DOMException {
return new AttrNSImpl(this, namespaceURI, qualifiedName);
}
@@ -2158,8 +2180,8 @@
* name contains an invalid character.
*/
public Attr createAttributeNS(String namespaceURI, String qualifiedName,
- String localpart)
- throws DOMException {
+ String localpart)
+ throws DOMException {
return new AttrNSImpl(this, namespaceURI, qualifiedName, localpart);
}
@@ -2180,7 +2202,7 @@
* @since WD-DOM-Level-2-19990923
*/
public NodeList getElementsByTagNameNS(String namespaceURI,
- String localName) {
+ String localName) {
return new DeepNodeListImpl(this, namespaceURI, localName);
}
@@ -2233,11 +2255,11 @@
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
- && XMLChar.isValidNCName(local);
+ && XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
- && XML11Char.isXML11ValidNCName(local);
+ && XML11Char.isXML11ValidNCName(local);
}
return validNCName;
@@ -2323,37 +2345,33 @@
* REVISIT: we could use a free list of UserDataRecord here
*/
public Object setUserData(Node n, String key,
- Object data, UserDataHandler handler) {
+ Object data, UserDataHandler handler) {
if (data == null) {
- if (userData != null) {
- Hashtable t = (Hashtable) userData.get(n);
+ if (nodeUserData != null) {
+ Map t = nodeUserData.get(n);
if (t != null) {
- Object o = t.remove(key);
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
+ UserDataRecord r = t.remove(key);
+ if (r != null) {
return r.fData;
}
}
}
return null;
- }
- else {
- Hashtable t;
- if (userData == null) {
- userData = new Hashtable();
- t = new Hashtable();
- userData.put(n, t);
- }
- else {
- t = (Hashtable) userData.get(n);
+ } else {
+ Map t;
+ if (nodeUserData == null) {
+ nodeUserData = new HashMap<>();
+ t = new HashMap<>();
+ nodeUserData.put(n, t);
+ } else {
+ t = nodeUserData.get(n);
if (t == null) {
- t = new Hashtable();
- userData.put(n, t);
+ t = new HashMap<>();
+ nodeUserData.put(n, t);
}
}
- Object o = t.put(key, new UserDataRecord(data, handler));
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
+ UserDataRecord r = t.put(key, new UserDataRecord(data, handler));
+ if (r != null) {
return r.fData;
}
return null;
@@ -2372,42 +2390,41 @@
* @since DOM Level 3
*/
public Object getUserData(Node n, String key) {
- if (userData == null) {
+ if (nodeUserData == null) {
return null;
}
- Hashtable t = (Hashtable) userData.get(n);
+ Map t = nodeUserData.get(n);
if (t == null) {
return null;
}
- Object o = t.get(key);
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
+ UserDataRecord r = t.get(key);
+ if (r != null) {
return r.fData;
}
return null;
}
- protected Hashtable getUserDataRecord(Node n){
- if (userData == null) {
+ protected Map getUserDataRecord(Node n) {
+ if (nodeUserData == null) {
return null;
}
- Hashtable t = (Hashtable) userData.get(n);
+ Map t = nodeUserData.get(n);
if (t == null) {
return null;
}
- return t;
- }
+ return t;
+ }
- /**
+ /**
* Remove user data table for the given node.
* @param n The node this operation applies to.
* @return The removed table.
*/
- Hashtable removeUserDataTable(Node n) {
- if (userData == null) {
+ Map removeUserDataTable(Node n) {
+ if (nodeUserData == null) {
return null;
}
- return (Hashtable) userData.get(n);
+ return nodeUserData.get(n);
}
/**
@@ -2415,11 +2432,13 @@
* @param n The node this operation applies to.
* @param data The user data table.
*/
- void setUserDataTable(Node n, Hashtable data) {
- if (userData == null)
- userData = new Hashtable();
+ void setUserDataTable(Node n, Map data) {
+ if (nodeUserData == null) {
+ nodeUserData = new HashMap<>();
+ }
+
if (data != null) {
- userData.put(n, data);
+ nodeUserData.put(n, data);
}
}
@@ -2430,41 +2449,39 @@
* @param operation The operation - import, clone, or delete.
*/
void callUserDataHandlers(Node n, Node c, short operation) {
- if (userData == null) {
+ if (nodeUserData == null) {
return;
}
- //Hashtable t = (Hashtable) userData.get(n);
- if(n instanceof NodeImpl){
- Hashtable t = ((NodeImpl)n).getUserDataRecord();
- if (t == null || t.isEmpty()) {
- return;
- }
- callUserDataHandlers(n, c, operation,t);
- }
+
+ if (n instanceof NodeImpl) {
+ Map t = ((NodeImpl) n).getUserDataRecord();
+ if (t == null || t.isEmpty()) {
+ return;
+ }
+ callUserDataHandlers(n, c, operation, t);
+ }
}
- /**
+ /**
* Call user data handlers when a node is deleted (finalized)
* @param n The node this operation applies to.
* @param c The copy node or null.
* @param operation The operation - import, clone, or delete.
- * @param handlers Data associated with n.
- */
- void callUserDataHandlers(Node n, Node c, short operation,Hashtable userData) {
+ * @param handlers Data associated with n.
+ */
+ void callUserDataHandlers(Node n, Node c, short operation, Map userData) {
if (userData == null || userData.isEmpty()) {
return;
}
- Enumeration keys = userData.keys();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- UserDataRecord r = (UserDataRecord) userData.get(key);
+ for (String key : userData.keySet()) {
+ UserDataRecord r = userData.get(key);
if (r.fHandler != null) {
r.fHandler.handle(operation, key, r.fData, n, c);
}
}
}
- /**
+ /**
* Call user data handlers to let them know the nodes they are related to
* are being deleted. The alternative would be to do that on Node but
* because the nodes are used as the keys we have a reference to them that
@@ -2479,29 +2496,29 @@
// 2. It affects the performance greatly in multi-thread environment.
// -SG
/*public void finalize() {
- if (userData == null) {
- return;
- }
- Enumeration nodes = userData.keys();
- while (nodes.hasMoreElements()) {
- Object node = nodes.nextElement();
- Hashtable t = (Hashtable) userData.get(node);
- if (t != null && !t.isEmpty()) {
- Enumeration keys = t.keys();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- UserDataRecord r = (UserDataRecord) t.get(key);
- if (r.fHandler != null) {
- r.fHandler.handle(UserDataHandler.NODE_DELETED,
- key, r.fData, null, null);
- }
- }
- }
- }
- }*/
+ if (userData == null) {
+ return;
+ }
+ Enumeration nodes = userData.keys();
+ while (nodes.hasMoreElements()) {
+ Object node = nodes.nextElement();
+ Hashtable t = (Hashtable) userData.get(node);
+ if (t != null && !t.isEmpty()) {
+ Enumeration keys = t.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ UserDataRecord r = (UserDataRecord) t.get(key);
+ if (r.fHandler != null) {
+ r.fHandler.handle(UserDataHandler.NODE_DELETED,
+ key, r.fData, null, null);
+ }
+ }
+ }
+ }
+ }*/
protected final void checkNamespaceWF( String qname, int colon1,
- int colon2) {
+ int colon2) {
if (!errorChecking) {
return;
@@ -2512,42 +2529,42 @@
if (colon1 == 0 || colon1 == qname.length() - 1 || colon2 != colon1) {
String msg =
DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
}
protected final void checkDOMNSErr(String prefix,
- String namespace) {
+ String namespace) {
if (errorChecking) {
if (namespace == null) {
String msg =
DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
else if (prefix.equals("xml")
- && !namespace.equals(NamespaceContext.XML_URI)) {
+ && !namespace.equals(NamespaceContext.XML_URI)) {
String msg =
DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
else if (
prefix.equals("xmlns")
- && !namespace.equals(NamespaceContext.XMLNS_URI)
- || (!prefix.equals("xmlns")
- && namespace.equals(NamespaceContext.XMLNS_URI))) {
+ && !namespace.equals(NamespaceContext.XMLNS_URI)
+ || (!prefix.equals("xmlns")
+ && namespace.equals(NamespaceContext.XMLNS_URI))) {
String msg =
DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NAMESPACE_ERR",
- null);
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR",
+ null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
}
@@ -2565,24 +2582,24 @@
return;
}
- // check that both prefix and local part match NCName
+ // check that both prefix and local part match NCName
boolean validNCName = false;
if (!xml11Version) {
validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
- && XMLChar.isValidNCName(local);
+ && XMLChar.isValidNCName(local);
}
else {
validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
- && XML11Char.isXML11ValidNCName(local);
+ && XML11Char.isXML11ValidNCName(local);
}
if (!validNCName) {
// REVISIT: add qname parameter to the message
String msg =
DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "INVALID_CHARACTER_ERR",
- null);
+ DOMMessageFormatter.DOM_DOMAIN,
+ "INVALID_CHARACTER_ERR",
+ null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
}
@@ -2629,14 +2646,14 @@
// Event related methods overidden in subclass
protected void addEventListener(NodeImpl node, String type,
- EventListener listener,
- boolean useCapture) {
+ EventListener listener,
+ boolean useCapture) {
// does nothing by default - overidden in subclass
}
protected void removeEventListener(NodeImpl node, String type,
- EventListener listener,
- boolean useCapture) {
+ EventListener listener,
+ boolean useCapture) {
// does nothing by default - overidden in subclass
}
@@ -2763,4 +2780,91 @@
void renamedElement(Element oldEl, Element newEl) {
}
+ /**
+ * @serialData Serialized fields. Convert Maps to Hashtables for backward
+ * compatibility.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ // Convert Maps to Hashtables
+ Hashtable> nud = null;
+ if (nodeUserData != null) {
+ nud = new Hashtable<>();
+ for (Map.Entry> e : nodeUserData.entrySet()) {
+ //e.getValue() will not be null since an entry is always put with a non-null value
+ nud.put(e.getKey(), new Hashtable<>(e.getValue()));
+ }
+ }
+
+ Hashtable ids = (identifiers == null)? null : new Hashtable<>(identifiers);
+ Hashtable nt = (nodeTable == null)? null : new Hashtable<>(nodeTable);
+
+ // Write serialized fields
+ ObjectOutputStream.PutField pf = out.putFields();
+ pf.put("docType", docType);
+ pf.put("docElement", docElement);
+ pf.put("fFreeNLCache", fFreeNLCache);
+ pf.put("encoding", encoding);
+ pf.put("actualEncoding", actualEncoding);
+ pf.put("version", version);
+ pf.put("standalone", standalone);
+ pf.put("fDocumentURI", fDocumentURI);
+
+ //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
+ pf.put("userData", nud);
+ pf.put("identifiers", ids);
+ pf.put("changes", changes);
+ pf.put("allowGrammarAccess", allowGrammarAccess);
+ pf.put("errorChecking", errorChecking);
+ pf.put("ancestorChecking", ancestorChecking);
+ pf.put("xmlVersionChanged", xmlVersionChanged);
+ pf.put("documentNumber", documentNumber);
+ pf.put("nodeCounter", nodeCounter);
+ pf.put("nodeTable", nt);
+ pf.put("xml11Version", xml11Version);
+ out.writeFields();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ // We have to read serialized fields first.
+ ObjectInputStream.GetField gf = in.readFields();
+ docType = (DocumentTypeImpl)gf.get("docType", null);
+ docElement = (ElementImpl)gf.get("docElement", null);
+ fFreeNLCache = (NodeListCache)gf.get("fFreeNLCache", null);
+ encoding = (String)gf.get("encoding", null);
+ actualEncoding = (String)gf.get("actualEncoding", null);
+ version = (String)gf.get("version", null);
+ standalone = gf.get("standalone", false);
+ fDocumentURI = (String)gf.get("fDocumentURI", null);
+
+ //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
+ Hashtable> nud =
+ (Hashtable>)gf.get("userData", null);
+
+ Hashtable ids = (Hashtable)gf.get("identifiers", null);
+
+ changes = gf.get("changes", 0);
+ allowGrammarAccess = gf.get("allowGrammarAccess", false);
+ errorChecking = gf.get("errorChecking", true);
+ ancestorChecking = gf.get("ancestorChecking", true);
+ xmlVersionChanged = gf.get("xmlVersionChanged", false);
+ documentNumber = gf.get("documentNumber", 0);
+ nodeCounter = gf.get("nodeCounter", 0);
+
+ Hashtable nt = (Hashtable)gf.get("nodeTable", null);
+
+ xml11Version = gf.get("xml11Version", false);
+
+ //convert Hashtables back to HashMaps
+ if (nud != null) {
+ nodeUserData = new HashMap<>();
+ for (Map.Entry> e : nud.entrySet()) {
+ nodeUserData.put(e.getKey(), new HashMap<>(e.getValue()));
+ }
+ }
+
+ if (ids != null) identifiers = new HashMap<>(ids);
+ if (nt != null) nodeTable = new HashMap<>(nt);
+ }
} // class CoreDocumentImpl
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java
--- a/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -21,7 +21,7 @@
package com.sun.org.apache.xerces.internal.dom;
import java.util.ArrayList;
-
+import java.util.HashMap;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -2057,9 +2057,9 @@
element+')');
}
- // create hashtable
+ // create Map
if (identifiers == null) {
- identifiers = new java.util.Hashtable();
+ identifiers = new HashMap<>();
}
// save ID and its associated element
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java
--- a/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001,2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,13 +20,19 @@
package com.sun.org.apache.xerces.internal.dom;
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Vector;
-
import com.sun.org.apache.xerces.internal.dom.events.EventImpl;
import com.sun.org.apache.xerces.internal.dom.events.MutationEventImpl;
-import org.w3c.dom.UserDataHandler;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
@@ -34,6 +40,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;
@@ -96,18 +103,33 @@
/** Iterators */
// REVISIT: Should this be transient? -Ac
- protected Vector iterators;
+ protected List iterators;
/** Ranges */
// REVISIT: Should this be transient? -Ac
- protected Vector ranges;
+ protected List ranges;
/** Table for event listeners registered to this document nodes. */
- protected Hashtable eventListeners;
+ protected Map> eventListeners;
/** Bypass mutation events firing. */
protected boolean mutationEvents = false;
+
+ /**
+ * @serialField iterators Vector Node iterators
+ * @serialField ranges Vector ranges
+ * @serialField eventListeners Hashtable Event listeners
+ * @serialField mutationEvents boolean Bypass mutation events firing
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
+ new ObjectStreamField[] {
+ new ObjectStreamField("iterators", Vector.class),
+ new ObjectStreamField("ranges", Vector.class),
+ new ObjectStreamField("eventListeners", Hashtable.class),
+ new ObjectStreamField("mutationEvents", boolean.class),
+ };
+
//
// Constructors
//
@@ -227,10 +249,10 @@
filter,
entityReferenceExpansion);
if (iterators == null) {
- iterators = new Vector();
+ iterators = new ArrayList<>();
}
- iterators.addElement(iterator);
+ iterators.add(iterator);
return iterator;
}
@@ -287,7 +309,7 @@
if (nodeIterator == null) return;
if (iterators == null) return;
- iterators.removeElement(nodeIterator);
+ iterators.remove(nodeIterator);
}
//
@@ -298,12 +320,11 @@
public Range createRange() {
if (ranges == null) {
- ranges = new Vector();
+ ranges = new ArrayList<>();
}
Range range = new RangeImpl(this);
-
- ranges.addElement(range);
+ ranges.add(range);
return range;
@@ -318,7 +339,7 @@
if (range == null) return;
if (ranges == null) return;
- ranges.removeElement(range);
+ ranges.remove(range);
}
/**
@@ -330,7 +351,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).receiveReplacedText(node);
+ ((RangeImpl)ranges.get(i)).receiveReplacedText(node);
}
}
}
@@ -344,7 +365,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).receiveDeletedText(node,
+ ((RangeImpl)ranges.get(i)).receiveDeletedText(node,
offset, count);
}
}
@@ -359,7 +380,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).receiveInsertedText(node,
+ ((RangeImpl)ranges.get(i)).receiveInsertedText(node,
offset, count);
}
}
@@ -374,7 +395,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).receiveSplitData(node,
+ ((RangeImpl)ranges.get(i)).receiveSplitData(node,
newNode, offset);
}
}
@@ -437,9 +458,9 @@
* node here won't be GC'ed as long as some listener is registered on it,
* since the eventsListeners table will have a reference to the node.
*/
- protected void setEventListeners(NodeImpl n, Vector listeners) {
+ private void setEventListeners(NodeImpl n, List listeners) {
if (eventListeners == null) {
- eventListeners = new Hashtable();
+ eventListeners = new HashMap<>();
}
if (listeners == null) {
eventListeners.remove(n);
@@ -457,11 +478,11 @@
/**
* Retreive event listener registered on a given node
*/
- protected Vector getEventListeners(NodeImpl n) {
+ private List getEventListeners(NodeImpl n) {
if (eventListeners == null) {
return null;
}
- return (Vector) eventListeners.get(n);
+ return eventListeners.get(n);
}
//
@@ -515,6 +536,7 @@
* @param useCapture True iff listener is registered on
* capturing phase rather than at-target or bubbling
*/
+ @Override
protected void addEventListener(NodeImpl node, String type,
EventListener listener, boolean useCapture)
{
@@ -527,12 +549,12 @@
// Simplest way to code that is to zap the previous entry, if any.
removeEventListener(node, type, listener, useCapture);
- Vector nodeListeners = getEventListeners(node);
+ List nodeListeners = getEventListeners(node);
if(nodeListeners == null) {
- nodeListeners = new Vector();
+ nodeListeners = new ArrayList<>();
setEventListeners(node, nodeListeners);
}
- nodeListeners.addElement(new LEntry(type, listener, useCapture));
+ nodeListeners.add(new LEntry(type, listener, useCapture));
// Record active listener
LCount lc = LCount.lookup(type);
@@ -558,6 +580,7 @@
* @param useCapture True iff listener is registered on
* capturing phase rather than at-target or bubbling
*/
+ @Override
protected void removeEventListener(NodeImpl node, String type,
EventListener listener,
boolean useCapture)
@@ -565,7 +588,7 @@
// If this couldn't be a valid listener registration, ignore request
if (type == null || type.equals("") || listener == null)
return;
- Vector nodeListeners = getEventListeners(node);
+ List nodeListeners = getEventListeners(node);
if (nodeListeners == null)
return;
@@ -573,12 +596,12 @@
// each listener may be registered only once per type per phase.
// count-down is OK for deletions!
for (int i = nodeListeners.size() - 1; i >= 0; --i) {
- LEntry le = (LEntry) nodeListeners.elementAt(i);
+ LEntry le = nodeListeners.get(i);
if (le.useCapture == useCapture && le.listener == listener &&
le.type.equals(type)) {
- nodeListeners.removeElementAt(i);
+ nodeListeners.remove(i);
// Storage management: Discard empty listener lists
- if (nodeListeners.size() == 0)
+ if (nodeListeners.isEmpty())
setEventListeners(node, null);
// Remove active listener
@@ -597,12 +620,13 @@
}
} // removeEventListener(NodeImpl,String,EventListener,boolean) :void
+ @Override
protected void copyEventListeners(NodeImpl src, NodeImpl tgt) {
- Vector nodeListeners = getEventListeners(src);
+ List nodeListeners = getEventListeners(src);
if (nodeListeners == null) {
return;
}
- setEventListeners(tgt, (Vector) nodeListeners.clone());
+ setEventListeners(tgt, new ArrayList<>(nodeListeners));
}
/**
@@ -655,6 +679,7 @@
* @return true if the event's preventDefault()
* method was invoked by an EventListener; otherwise false.
*/
+ @Override
protected boolean dispatchEvent(NodeImpl node, Event event) {
if (event == null) return false;
@@ -691,11 +716,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);
+ List 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();
}
@@ -710,15 +735,15 @@
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);
+ List nodeListeners = getEventListeners(nn);
if (nodeListeners != null) {
- Vector nl = (Vector) nodeListeners.clone();
+ List nl = (List)((ArrayList)nodeListeners).clone();
// call listeners in the order in which they got registered
int nlsize = nl.size();
for (int i = 0; i < nlsize; i++) {
- LEntry le = (LEntry) nl.elementAt(i);
+ LEntry le = nl.get(i);
if (le.useCapture && le.type.equals(evt.type) &&
nodeListeners.contains(le)) {
try {
@@ -741,13 +766,13 @@
// node are _not_ invoked, even during the capture phase.
evt.eventPhase = Event.AT_TARGET;
evt.currentTarget = node;
- Vector nodeListeners = getEventListeners(node);
+ List nodeListeners = getEventListeners(node);
if (!evt.stopPropagation && nodeListeners != null) {
- Vector nl = (Vector) nodeListeners.clone();
+ List nl = (List)((ArrayList)nodeListeners).clone();
// call listeners in the order in which they got registered
int nlsize = nl.size();
for (int i = 0; i < nlsize; i++) {
- LEntry le = (LEntry) nl.elementAt(i);
+ LEntry le = (LEntry) nl.get(i);
if (!le.useCapture && le.type.equals(evt.type) &&
nodeListeners.contains(le)) {
try {
@@ -772,16 +797,16 @@
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) {
- Vector nl = (Vector) nodeListeners.clone();
+ List nl = (List)((ArrayList)nodeListeners).clone();
// call listeners in the order in which they got
// registered
int nlsize = nl.size();
for (int i = 0; i < nlsize; i++) {
- LEntry le = (LEntry) nl.elementAt(i);
+ LEntry le = nl.get(i);
if (!le.useCapture && le.type.equals(evt.type) &&
nodeListeners.contains(le)) {
try {
@@ -1118,7 +1143,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).insertedNodeFromDOM(newInternal);
+ ((RangeImpl)ranges.get(i)).insertedNodeFromDOM(newInternal);
}
}
}
@@ -1132,7 +1157,7 @@
if (iterators != null) {
int size = iterators.size();
for (int i = 0; i != size; i++) {
- ((NodeIteratorImpl)iterators.elementAt(i)).removeNode(oldChild);
+ ((NodeIteratorImpl)iterators.get(i)).removeNode(oldChild);
}
}
@@ -1140,7 +1165,7 @@
if (ranges != null) {
int size = ranges.size();
for (int i = 0; i != size; i++) {
- ((RangeImpl)ranges.elementAt(i)).removeNode(oldChild);
+ ((RangeImpl)ranges.get(i)).removeNode(oldChild);
}
}
@@ -1302,4 +1327,53 @@
// REVISIT: To be implemented!!!
}
+
+ /**
+ * @serialData Serialized fields. Convert Maps to Hashtables and Lists
+ * to Vectors for backward compatibility.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ // Convert Maps to Hashtables, Lists to Vectors
+ Vector it = (iterators == null)? null : new Vector<>(iterators);
+ Vector r = (ranges == null)? null : new Vector<>(ranges);
+
+ Hashtable> el = null;
+ if (eventListeners != null) {
+ el = new Hashtable<>();
+ for (Map.Entry> e : eventListeners.entrySet()) {
+ el.put(e.getKey(), new Vector<>(e.getValue()));
+ }
+ }
+
+ // Write serialized fields
+ ObjectOutputStream.PutField pf = out.putFields();
+ pf.put("iterators", it);
+ pf.put("ranges", r);
+ pf.put("eventListeners", el);
+ pf.put("mutationEvents", mutationEvents);
+ out.writeFields();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ // We have to read serialized fields first.
+ ObjectInputStream.GetField gf = in.readFields();
+ Vector it = (Vector)gf.get("iterators", null);
+ Vector r = (Vector)gf.get("ranges", null);
+ Hashtable> el =
+ (Hashtable>)gf.get("eventListeners", null);
+
+ mutationEvents = gf.get("mutationEvents", false);
+
+ //convert Hashtables back to HashMaps and Vectors to Lists
+ if (it != null) iterators = new ArrayList<>(it);
+ if (r != null) ranges = new ArrayList<>(r);
+ if (el != null) {
+ eventListeners = new HashMap<>();
+ for (Map.Entry> e : el.entrySet()) {
+ eventListeners.put(e.getKey(), new ArrayList<>(e.getValue()));
+ }
+ }
+ }
} // class DocumentImpl
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java
--- a/src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,11 +20,17 @@
package com.sun.org.apache.xerces.internal.dom;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
import org.w3c.dom.DOMException;
import org.w3c.dom.DocumentType;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import org.w3c.dom.NamedNodeMap;
-import java.util.Hashtable;
import org.w3c.dom.UserDataHandler;
/**
@@ -95,10 +101,37 @@
// a number, on demand, for ordering purposes for compareDocumentPosition
private int doctypeNumber=0;
+ private Map userData = null;
+
+
+ /**
+ * @serialField name String document type name
+ * @serialField entities NamedNodeMapImpl entities
+ * @serialField notations NamedNodeMapImpl notations
+ * @serialField elements NamedNodeMapImpl elements
+ * @serialField publicID String support public ID
+ * @serialField systemID String support system ID
+ * @serialField internalSubset String support internal subset
+ * @serialField doctypeNumber int Doctype number
+ * @serialField userData Hashtable user data
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
+ new ObjectStreamField[] {
+ new ObjectStreamField("name", String.class),
+ new ObjectStreamField("entities", NamedNodeMapImpl.class),
+ new ObjectStreamField("notations", NamedNodeMapImpl.class),
+ new ObjectStreamField("elements", NamedNodeMapImpl.class),
+ new ObjectStreamField("publicID", String.class),
+ new ObjectStreamField("systemID", String.class),
+ new ObjectStreamField("internalSubset", String.class),
+ new ObjectStreamField("doctypeNumber", int.class),
+ new ObjectStreamField("userData", Hashtable.class),
+ };
+
//
// Constructors
//
- private Hashtable userData = null;
+
/** Factory method for creating a document type node. */
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name) {
super(ownerDocument);
@@ -445,22 +478,20 @@
public Object setUserData(String key,
Object data, UserDataHandler handler) {
if(userData == null)
- userData = new Hashtable();
+ userData = new HashMap<>();
if (data == null) {
if (userData != null) {
- Object o = userData.remove(key);
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
- return r.fData;
+ UserDataRecord udr = userData.remove(key);
+ if (udr != null) {
+ return udr.fData;
}
}
return null;
}
else {
- Object o = userData.put(key, new UserDataRecord(data, handler));
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
- return r.fData;
+ UserDataRecord udr = userData.put(key, new UserDataRecord(data, handler));
+ if (udr != null) {
+ return udr.fData;
}
}
return null;
@@ -470,16 +501,58 @@
if (userData == null) {
return null;
}
- Object o = userData.get(key);
- if (o != null) {
- UserDataRecord r = (UserDataRecord) o;
- return r.fData;
+ UserDataRecord udr = userData.get(key);
+ if (udr != null) {
+ return udr.fData;
}
return null;
}
- protected Hashtable getUserDataRecord(){
+ @Override
+ protected Map getUserDataRecord(){
return userData;
}
+ /**
+ * @serialData Serialized fields. Convert Map to Hashtable for backward
+ * compatibility.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ // Convert the HashMap to Hashtable
+ Hashtable ud = (userData == null)? null : new Hashtable<>(userData);
+
+ // Write serialized fields
+ ObjectOutputStream.PutField pf = out.putFields();
+ pf.put("name", name);
+ pf.put("entities", entities);
+ pf.put("notations", notations);
+ pf.put("elements", elements);
+ pf.put("publicID", publicID);
+ pf.put("systemID", systemID);
+ pf.put("internalSubset", internalSubset);
+ pf.put("doctypeNumber", doctypeNumber);
+ pf.put("userData", ud);
+ out.writeFields();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ // We have to read serialized fields first.
+ ObjectInputStream.GetField gf = in.readFields();
+ name = (String)gf.get("name", null);
+ entities = (NamedNodeMapImpl)gf.get("entities", null);
+ notations = (NamedNodeMapImpl)gf.get("notations", null);
+ elements = (NamedNodeMapImpl)gf.get("elements", null);
+ publicID = (String)gf.get("publicID", null);
+ systemID = (String)gf.get("systemID", null);
+ internalSubset = (String)gf.get("internalSubset", null);
+ doctypeNumber = gf.get("doctypeNumber", 0);
+
+ Hashtable ud =
+ (Hashtable)gf.get("userData", null);
+
+ //convert the Hashtable back to HashMap
+ if (ud != null) userData = new HashMap<>(ud);
+ }
} // class DocumentTypeImpl
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/LCount.java
--- a/src/com/sun/org/apache/xerces/internal/dom/LCount.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/LCount.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -22,20 +22,13 @@
/** Internal class LCount is used to track the number of
listeners registered for a given event name, as an entry
- in a global hashtable. This should allow us to avoid generating,
- or discard, events for which no listeners are registered.
+ in a global Map. This should allow us to avoid generating,
+ or discarding, events for which no listeners are registered.
***** There should undoubtedly be methods here to manipulate
this table. At the moment that code's residing in NodeImpl.
Move it when we have a chance to do so. Sorry; we were
rushed.
-
- ???? CONCERN: Hashtables are known to be "overserialized" in
- current versions of Java. That may impact performance.
-
- ???? CONCERN: The hashtable should probably be a per-document object.
- Finer granularity would be even better, but would cost more cycles to
- resolve and might not save enough event traffic to be worth the investment.
*/
/**
* @xerces.internal
@@ -44,7 +37,7 @@
class LCount
{
- static java.util.Hashtable lCounts=new java.util.Hashtable();
+ static final java.util.Map lCounts=new java.util.concurrent.ConcurrentHashMap<>();
public int captures=0,bubbles=0,defaults, total=0;
static LCount lookup(String evtName)
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java
--- a/src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/NodeImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -23,15 +23,14 @@
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import java.util.Hashtable;
-
-import org.w3c.dom.UserDataHandler;
+import java.util.Map;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.UserDataHandler;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
@@ -1793,7 +1792,7 @@
return ownerDocument().getUserData(this, key);
}
- protected Hashtable getUserDataRecord(){
+ protected Map getUserDataRecord(){
return ownerDocument().getUserDataRecord(this);
}
@@ -1845,7 +1844,7 @@
* NON-DOM: As an alternative to subclassing the DOM, this implementation
* has been extended with the ability to attach an object to each node.
* (If you need multiple objects, you can attach a collection such as a
- * vector or hashtable, then attach your application information to that.)
+ * List or Map, then attach your application information to that.)
* Important Note: You are responsible for removing references
* to your data on nodes that are no longer used. Failure to do so will
* prevent the nodes, your data is attached to, to be garbage collected
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/dom/ParentNode.java
--- a/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,10 +20,10 @@
package com.sun.org.apache.xerces.internal.dom;
-import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.Serializable;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
@@ -1023,7 +1023,7 @@
/*
* a class to store some user data along with its handler
*/
- class UserDataRecord implements Serializable {
+ protected class UserDataRecord implements Serializable {
/** Serialization version. */
private static final long serialVersionUID = 3258126977134310455L;
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,15 +1,15 @@
/*
- * Copyright (c) 2003, 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
*/
-
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
- * 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
+ * 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,
@@ -44,12 +44,11 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Stack;
-import javax.xml.XMLConstants;
import javax.xml.stream.XMLInputFactory;
@@ -365,7 +364,7 @@
// entities
/** Entities. */
- protected Hashtable fEntities = new Hashtable();
+ protected Map fEntities = new HashMap<>();
/** Entity stack. */
protected Stack fEntityStack = new Stack();
@@ -852,7 +851,7 @@
*/
public boolean isExternalEntity(String entityName) {
- Entity entity = (Entity)fEntities.get(entityName);
+ Entity entity = fEntities.get(entityName);
if (entity == null) {
return false;
}
@@ -869,7 +868,7 @@
*/
public boolean isEntityDeclInExternalSubset(String entityName) {
- Entity entity = (Entity)fEntities.get(entityName);
+ Entity entity = fEntities.get(entityName);
if (entity == null) {
return false;
}
@@ -899,13 +898,13 @@
public boolean isDeclaredEntity(String entityName) {
- Entity entity = (Entity)fEntities.get(entityName);
+ Entity entity = fEntities.get(entityName);
return entity != null;
}
public boolean isUnparsedEntity(String entityName) {
- Entity entity = (Entity)fEntities.get(entityName);
+ Entity entity = fEntities.get(entityName);
if (entity == null) {
return false;
}
@@ -1111,7 +1110,7 @@
throws IOException, XNIException {
// was entity declared?
- Entity entity = (Entity)fEntityStorage.getEntity(entityName);
+ Entity entity = fEntityStorage.getEntity(entityName);
if (entity == null) {
if (fEntityHandler != null) {
String encoding = null;
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,68 +1,24 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2004 The Apache Software Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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 com.sun.org.apache.xerces.internal.impl;
-import java.util.Hashtable;
-import java.util.Locale;
-
import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
import com.sun.org.apache.xerces.internal.util.ErrorHandlerProxy;
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
@@ -73,6 +29,9 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
import org.xml.sax.ErrorHandler;
/**
@@ -189,7 +148,7 @@
protected Locale fLocale;
/** Mapping of Message formatters for domains. */
- protected Hashtable fMessageFormatters;
+ protected Map fMessageFormatters;
/** Error handler. */
protected XMLErrorHandler fErrorHandler;
@@ -233,7 +192,7 @@
// caller to specify the location of the error being
// reported. -Ac
- fMessageFormatters = new Hashtable();
+ fMessageFormatters = new HashMap<>();
} // ()
@@ -291,7 +250,7 @@
* @param domain The domain of the message formatter.
*/
public MessageFormatter getMessageFormatter(String domain) {
- return (MessageFormatter)fMessageFormatters.get(domain);
+ return fMessageFormatters.get(domain);
} // getMessageFormatter(String):MessageFormatter
/**
@@ -301,7 +260,7 @@
* @param domain The domain of the message formatter.
*/
public MessageFormatter removeMessageFormatter(String domain) {
- return (MessageFormatter) fMessageFormatters.remove(domain);
+ return fMessageFormatters.remove(domain);
} // removeMessageFormatter(String):MessageFormatter
/**
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,22 +25,21 @@
package com.sun.org.apache.xerces.internal.impl;
+import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
+import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
+import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
+import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
import com.sun.xml.internal.stream.Entity;
import com.sun.xml.internal.stream.StaxErrorReporter;
import com.sun.xml.internal.stream.XMLEntityStorage;
+import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
+import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
import com.sun.xml.internal.stream.events.EntityDeclarationImpl;
import com.sun.xml.internal.stream.events.NotationDeclarationImpl;
-import javax.xml.namespace.NamespaceContext;
-import com.sun.org.apache.xerces.internal.xni.XNIException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-import javax.xml.stream.events.XMLEvent;
-import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
-import com.sun.org.apache.xerces.internal.util.SymbolTable;
-import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
-import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
@@ -48,20 +47,16 @@
import java.io.Reader;
import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
-import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
-import com.sun.org.apache.xerces.internal.util.XMLChar;
-import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
-import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
-import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
-import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
+import javax.xml.stream.events.XMLEvent;
/** This class implements javax.xml.stream.XMLStreamReader. It makes use of XML*Scanner classes to
* derive most of its functionality. If desired, Application can reuse this instance by calling
@@ -1173,7 +1168,7 @@
public boolean hasText() {
if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
- return fScanner.getCharacterData().length > 0 ? true : false;
+ return fScanner.getCharacterData().length > 0;
} else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
String name = fScanner.getEntityName();
if(name != null){
@@ -1185,9 +1180,9 @@
if(en == null)
return false;
if(en.isExternal()){
- return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
+ return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
} else{
- return ((Entity.InternalEntity)en).text != null ? true : false ;
+ return ((Entity.InternalEntity)en).text != null ;
}
}else
return false;
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java
--- a/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,69 +1,25 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 1999-2002 The Apache Software Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org. For more
- * information on the Apache Software Foundation, please see
- * .
+ * 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 com.sun.org.apache.xerces.internal.impl.dtd;
-import java.util.ArrayList;
-import java.util.Hashtable;
-
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMBinOp;
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMLeaf;
@@ -88,10 +44,13 @@
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
/**
* A DTD grammar. This class implements the XNI handler interfaces
- * for DTD information so that it can build the approprate validation
+ * for DTD information so that it can build the appropriate validation
* structures automatically from the callbacks.
*
* @xerces.internal
@@ -251,13 +210,13 @@
// other information
/** Element index mapping table. */
- private QNameHashtable fElementIndexMap = new QNameHashtable();
+ private final Map fElementIndexMap = new HashMap<>();
/** Entity index mapping table. */
- private QNameHashtable fEntityIndexMap = new QNameHashtable();
+ private final Map fEntityIndexMap = new HashMap<>();
/** Notation index mapping table. */
- private QNameHashtable fNotationIndexMap = new QNameHashtable();
+ private final Map fNotationIndexMap = new HashMap<>();
// temp variables
@@ -291,7 +250,7 @@
private XMLContentSpec fContentSpec = new XMLContentSpec();
/** table of XMLElementDecl */
- Hashtable fElementDeclTab = new Hashtable();
+ Map fElementDeclTab = new HashMap<>();
/** Children content model operation stack. */
private short[] fOpStack = null;
@@ -516,7 +475,7 @@
public void elementDecl(String name, String contentModel, Augmentations augs)
throws XNIException {
- XMLElementDecl tmpElementDecl = (XMLElementDecl) fElementDeclTab.get(name) ;
+ XMLElementDecl tmpElementDecl = fElementDeclTab.get(name) ;
// check if it is already defined
if ( tmpElementDecl != null ) {
@@ -606,7 +565,7 @@
String defaultType, XMLString defaultValue,
XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
- if ( this.fElementDeclTab.containsKey( (String) elementName) ) {
+ if ( this.fElementDeclTab.containsKey(elementName) ) {
//if ElementDecl has already being created in the Grammar then remove from table,
//this.fElementDeclTab.remove( (String) elementName );
}
@@ -989,7 +948,7 @@
public void startContentModel(String elementName, Augmentations augs)
throws XNIException {
- XMLElementDecl elementDecl = (XMLElementDecl) this.fElementDeclTab.get( elementName);
+ XMLElementDecl elementDecl = this.fElementDeclTab.get(elementName);
if ( elementDecl != null ) {
fElementDecl = elementDecl;
}
@@ -1216,7 +1175,10 @@
* @return index of the elementDeclName in scope
*/
public int getElementDeclIndex(String elementDeclName) {
- int mapping = fElementIndexMap.get(elementDeclName);
+ Integer mapping = fElementIndexMap.get(elementDeclName);
+ if (mapping == null) {
+ mapping = -1;
+ }
//System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping);
return mapping;
} // getElementDeclIndex(String):int
@@ -1393,7 +1355,7 @@
* @return the index of the EntityDecl
*/
public int getEntityDeclIndex(String entityDeclName) {
- if (entityDeclName == null) {
+ if (entityDeclName == null || fEntityIndexMap.get(entityDeclName) == null) {
return -1;
}
@@ -1436,7 +1398,7 @@
* @return the index if found a notation with the name, otherwise -1.
*/
public int getNotationDeclIndex(String notationDeclName) {
- if (notationDeclName == null) {
+ if (notationDeclName == null || fNotationIndexMap.get(notationDeclName) == null) {
return -1;
}
@@ -2670,108 +2632,6 @@
} // class ChildrenList
//
- // Classes
- //
-
- /**
- * A simple Hashtable implementation that takes a tuple (String, String)
- * as the key and a int as value.
- *
- * @xerces.internal
- *
- * @author Eric Ye, IBM
- * @author Andy Clark, IBM
- */
- protected static final class QNameHashtable {
-
- //
- // Constants
- //
-
- /** Initial bucket size (4). */
- private static final int INITIAL_BUCKET_SIZE = 4;
-
- // NOTE: Changed previous hashtable size from 512 to 101 so
- // that we get a better distribution for hashing. -Ac
- /** Hashtable size (101). */
- private static final int HASHTABLE_SIZE = 101;
-
- //
- // Data
- //
- private Object[][] fHashTable = new Object[HASHTABLE_SIZE][];
-
- //
- // Public methods
- //
- /** Associates the given value with the specified key tuple. */
- public void put(String key, int value) {
-
- int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
- Object[] bucket = fHashTable[hash];
-
- if (bucket == null) {
- bucket = new Object[1 + 2*INITIAL_BUCKET_SIZE];
- bucket[0] = new int[]{1};
- bucket[1] = key;
- bucket[2] = new int[]{value};
- fHashTable[hash] = bucket;
- } else {
- int count = ((int[])bucket[0])[0];
- int offset = 1 + 2*count;
- if (offset == bucket.length) {
- int newSize = count + INITIAL_BUCKET_SIZE;
- Object[] newBucket = new Object[1 + 2*newSize];
- System.arraycopy(bucket, 0, newBucket, 0, offset);
- bucket = newBucket;
- fHashTable[hash] = bucket;
- }
- boolean found = false;
- int j=1;
- for (int i=0; i "+value+')');
- //System.out.println("get("+key+") -> "+get(key));
-
- } // put(int,String,String,int)
-
- /** Returns the value associated with the specified key tuple. */
- public int get(String key) {
- int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
- Object[] bucket = fHashTable[hash];
-
- if (bucket == null) {
- return -1;
- }
- int count = ((int[])bucket[0])[0];
-
- int j=1;
- for (int i=0; i.
+ * 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 com.sun.org.apache.xerces.internal.impl.dtd;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
/**
* This very simple class is the skeleton of what the DTDValidator could use
@@ -87,7 +47,7 @@
//
/** Grammars associated with element root name. */
- protected Hashtable fGrammars;
+ protected Map fGrammars;
// the unique grammar from fGrammars (or that we're
// building) that is used in validation.
@@ -102,7 +62,7 @@
/** Default constructor. */
public DTDGrammarBucket() {
- fGrammars = new Hashtable();
+ fGrammars = new HashMap<>();
} // ()
//
@@ -122,7 +82,7 @@
// retrieve a DTDGrammar given an XMLDTDDescription
public DTDGrammar getGrammar(XMLGrammarDescription desc) {
- return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
+ return fGrammars.get((XMLDTDDescription)desc);
} // putGrammar(DTDGrammar)
public void clear() {
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001, 2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,7 +20,7 @@
package com.sun.org.apache.xerces.internal.impl.dv;
-import java.util.Hashtable;
+import java.util.Map;
import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
/**
@@ -80,10 +80,10 @@
public abstract DatatypeValidator getBuiltInDV(String name);
/**
- * get all built-in DVs, which are stored in a hashtable keyed by the name
+ * get all built-in DVs, which are stored in a map keyed by the name
*
- * @return a hashtable which contains all datatypes
+ * @return a map which contains all datatypes
*/
- public abstract Hashtable getBuiltInTypes();
+ public abstract Map getBuiltInTypes();
}
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/DTDDVFactoryImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001, 2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -22,7 +22,9 @@
import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;
import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
-import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
/**
* the factory to create/return built-in schema DVs and create user-defined DVs
@@ -34,9 +36,25 @@
*/
public class DTDDVFactoryImpl extends DTDDVFactory {
- static Hashtable fBuiltInTypes = new Hashtable();
+ static final Map fBuiltInTypes;
static {
- createBuiltInTypes();
+ Map builtInTypes = new HashMap<>();
+ DatatypeValidator dvTemp;
+
+ builtInTypes.put("string", new StringDatatypeValidator());
+ builtInTypes.put("ID", new IDDatatypeValidator());
+ dvTemp = new IDREFDatatypeValidator();
+ builtInTypes.put("IDREF", dvTemp);
+ builtInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
+ dvTemp = new ENTITYDatatypeValidator();
+ builtInTypes.put("ENTITY", new ENTITYDatatypeValidator());
+ builtInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
+ builtInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
+ dvTemp = new NMTOKENDatatypeValidator();
+ builtInTypes.put("NMTOKEN", dvTemp);
+ builtInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
+
+ fBuiltInTypes = Collections.unmodifiableMap(builtInTypes);
}
/**
@@ -45,37 +63,19 @@
* @param name the name of the datatype
* @return the datatype validator of the given name
*/
+ @Override
public DatatypeValidator getBuiltInDV(String name) {
- return (DatatypeValidator)fBuiltInTypes.get(name);
+ return fBuiltInTypes.get(name);
}
/**
- * get all built-in DVs, which are stored in a hashtable keyed by the name
+ * get all built-in DVs, which are stored in a Map keyed by the name
*
- * @return a hashtable which contains all datatypes
+ * @return a Map which contains all datatypes
*/
- public Hashtable getBuiltInTypes() {
- return (Hashtable)fBuiltInTypes.clone();
+ @Override
+ public Map getBuiltInTypes() {
+ return new HashMap<>(fBuiltInTypes);
}
- // create all built-in types
- static void createBuiltInTypes() {
-
- DatatypeValidator dvTemp;
-
- fBuiltInTypes.put("string", new StringDatatypeValidator());
- fBuiltInTypes.put("ID", new IDDatatypeValidator());
- dvTemp = new IDREFDatatypeValidator();
- fBuiltInTypes.put("IDREF", dvTemp);
- fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
- dvTemp = new ENTITYDatatypeValidator();
- fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
- fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
- fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
- dvTemp = new NMTOKENDatatypeValidator();
- fBuiltInTypes.put("NMTOKEN", dvTemp);
- fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
-
- }//createBuiltInTypes()
-
}// DTDDVFactoryImpl
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java
--- a/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/dv/dtd/XML11DTDDVFactoryImpl.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2001, 2002,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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,10 +20,10 @@
package com.sun.org.apache.xerces.internal.impl.dv.dtd;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
/**
* the factory to create/return built-in XML 1.1 DVs and create user-defined DVs
@@ -35,7 +35,18 @@
*/
public class XML11DTDDVFactoryImpl extends DTDDVFactoryImpl {
- static Hashtable fXML11BuiltInTypes = new Hashtable();
+ static Map XML11BUILTINTYPES;
+ static {
+ Map xml11BuiltInTypes = new HashMap<>();
+ xml11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
+ DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
+ xml11BuiltInTypes.put("XML11IDREF", dvTemp);
+ xml11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
+ dvTemp = new XML11NMTOKENDatatypeValidator();
+ xml11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
+ xml11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
+ XML11BUILTINTYPES = Collections.unmodifiableMap(xml11BuiltInTypes);
+ } //
/**
* return a dtd type of the given name
@@ -45,38 +56,24 @@
* @param name the name of the datatype
* @return the datatype validator of the given name
*/
+ @Override
public DatatypeValidator getBuiltInDV(String name) {
- if(fXML11BuiltInTypes.get(name) != null) {
- return (DatatypeValidator)fXML11BuiltInTypes.get(name);
+ if(XML11BUILTINTYPES.get(name) != null) {
+ return XML11BUILTINTYPES.get(name);
}
- return (DatatypeValidator)fBuiltInTypes.get(name);
+ return fBuiltInTypes.get(name);
}
/**
- * get all built-in DVs, which are stored in a hashtable keyed by the name
+ * get all built-in DVs, which are stored in a Map keyed by the name
* New XML 1.1 datatypes are inserted.
*
- * @return a hashtable which contains all datatypes
+ * @return a Map which contains all datatypes
*/
- public Hashtable getBuiltInTypes() {
- Hashtable toReturn = (Hashtable)fBuiltInTypes.clone();
- Enumeration xml11Keys = fXML11BuiltInTypes.keys();
- while (xml11Keys.hasMoreElements()) {
- Object key = xml11Keys.nextElement();
- toReturn.put(key, fXML11BuiltInTypes.get(key));
- }
+ @Override
+ public Map getBuiltInTypes() {
+ final HashMap toReturn = new HashMap<>(fBuiltInTypes);
+ toReturn.putAll(XML11BUILTINTYPES);
return toReturn;
}
-
- static {
- fXML11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
- DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
- fXML11BuiltInTypes.put("XML11IDREF", dvTemp);
- fXML11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
- dvTemp = new XML11NMTOKENDatatypeValidator();
- fXML11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
- fXML11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
- } //
-
-
}//XML11DTDDVFactoryImpl
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/XPath.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2000-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,13 +20,14 @@
package com.sun.org.apache.xerces.internal.impl.xpath;
-import java.util.Vector;
-
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
-import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
/**
* Bare minimum XPath parser.
@@ -858,10 +859,10 @@
private SymbolTable fSymbolTable;
// REVISIT: Code something better here. -Ac
- private java.util.Hashtable fSymbolMapping = new java.util.Hashtable();
+ private Map fSymbolMapping = new HashMap<>();
// REVISIT: Code something better here. -Ac
- private java.util.Hashtable fTokenNames = new java.util.Hashtable();
+ private Map fTokenNames = new HashMap<>();
/**
* Current position in the token list.
@@ -882,57 +883,57 @@
"self",
};
for (int i = 0; i < symbols.length; i++) {
- fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), new Integer(i));
+ fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), i);
}
- fTokenNames.put(new Integer(EXPRTOKEN_OPEN_PAREN), "EXPRTOKEN_OPEN_PAREN");
- fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_PAREN), "EXPRTOKEN_CLOSE_PAREN");
- fTokenNames.put(new Integer(EXPRTOKEN_OPEN_BRACKET), "EXPRTOKEN_OPEN_BRACKET");
- fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_BRACKET), "EXPRTOKEN_CLOSE_BRACKET");
- fTokenNames.put(new Integer(EXPRTOKEN_PERIOD), "EXPRTOKEN_PERIOD");
- fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_PERIOD), "EXPRTOKEN_DOUBLE_PERIOD");
- fTokenNames.put(new Integer(EXPRTOKEN_ATSIGN), "EXPRTOKEN_ATSIGN");
- fTokenNames.put(new Integer(EXPRTOKEN_COMMA), "EXPRTOKEN_COMMA");
- fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_COLON), "EXPRTOKEN_DOUBLE_COLON");
- fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_ANY), "EXPRTOKEN_NAMETEST_ANY");
- fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_NAMESPACE), "EXPRTOKEN_NAMETEST_NAMESPACE");
- fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_QNAME), "EXPRTOKEN_NAMETEST_QNAME");
- fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_COMMENT), "EXPRTOKEN_NODETYPE_COMMENT");
- fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_TEXT), "EXPRTOKEN_NODETYPE_TEXT");
- fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_PI), "EXPRTOKEN_NODETYPE_PI");
- fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_NODE), "EXPRTOKEN_NODETYPE_NODE");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_AND), "EXPRTOKEN_OPERATOR_AND");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_OR), "EXPRTOKEN_OPERATOR_OR");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MOD), "EXPRTOKEN_OPERATOR_MOD");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DIV), "EXPRTOKEN_OPERATOR_DIV");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MULT), "EXPRTOKEN_OPERATOR_MULT");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_SLASH), "EXPRTOKEN_OPERATOR_SLASH");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DOUBLE_SLASH), "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_UNION), "EXPRTOKEN_OPERATOR_UNION");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_PLUS), "EXPRTOKEN_OPERATOR_PLUS");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MINUS), "EXPRTOKEN_OPERATOR_MINUS");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_EQUAL), "EXPRTOKEN_OPERATOR_EQUAL");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_NOT_EQUAL), "EXPRTOKEN_OPERATOR_NOT_EQUAL");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS), "EXPRTOKEN_OPERATOR_LESS");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS_EQUAL), "EXPRTOKEN_OPERATOR_LESS_EQUAL");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER), "EXPRTOKEN_OPERATOR_GREATER");
- fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER_EQUAL), "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
- fTokenNames.put(new Integer(EXPRTOKEN_FUNCTION_NAME), "EXPRTOKEN_FUNCTION_NAME");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR), "EXPRTOKEN_AXISNAME_ANCESTOR");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF), "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ATTRIBUTE), "EXPRTOKEN_AXISNAME_ATTRIBUTE");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_CHILD), "EXPRTOKEN_AXISNAME_CHILD");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT), "EXPRTOKEN_AXISNAME_DESCENDANT");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF), "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING), "EXPRTOKEN_AXISNAME_FOLLOWING");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING), "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_NAMESPACE), "EXPRTOKEN_AXISNAME_NAMESPACE");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PARENT), "EXPRTOKEN_AXISNAME_PARENT");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING), "EXPRTOKEN_AXISNAME_PRECEDING");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING), "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
- fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_SELF), "EXPRTOKEN_AXISNAME_SELF");
- fTokenNames.put(new Integer(EXPRTOKEN_LITERAL), "EXPRTOKEN_LITERAL");
- fTokenNames.put(new Integer(EXPRTOKEN_NUMBER), "EXPRTOKEN_NUMBER");
- fTokenNames.put(new Integer(EXPRTOKEN_VARIABLE_REFERENCE), "EXPRTOKEN_VARIABLE_REFERENCE");
+ fTokenNames.put(EXPRTOKEN_OPEN_PAREN, "EXPRTOKEN_OPEN_PAREN");
+ fTokenNames.put(EXPRTOKEN_CLOSE_PAREN, "EXPRTOKEN_CLOSE_PAREN");
+ fTokenNames.put(EXPRTOKEN_OPEN_BRACKET, "EXPRTOKEN_OPEN_BRACKET");
+ fTokenNames.put(EXPRTOKEN_CLOSE_BRACKET, "EXPRTOKEN_CLOSE_BRACKET");
+ fTokenNames.put(EXPRTOKEN_PERIOD, "EXPRTOKEN_PERIOD");
+ fTokenNames.put(EXPRTOKEN_DOUBLE_PERIOD, "EXPRTOKEN_DOUBLE_PERIOD");
+ fTokenNames.put(EXPRTOKEN_ATSIGN, "EXPRTOKEN_ATSIGN");
+ fTokenNames.put(EXPRTOKEN_COMMA, "EXPRTOKEN_COMMA");
+ fTokenNames.put(EXPRTOKEN_DOUBLE_COLON, "EXPRTOKEN_DOUBLE_COLON");
+ fTokenNames.put(EXPRTOKEN_NAMETEST_ANY, "EXPRTOKEN_NAMETEST_ANY");
+ fTokenNames.put(EXPRTOKEN_NAMETEST_NAMESPACE, "EXPRTOKEN_NAMETEST_NAMESPACE");
+ fTokenNames.put(EXPRTOKEN_NAMETEST_QNAME, "EXPRTOKEN_NAMETEST_QNAME");
+ fTokenNames.put(EXPRTOKEN_NODETYPE_COMMENT, "EXPRTOKEN_NODETYPE_COMMENT");
+ fTokenNames.put(EXPRTOKEN_NODETYPE_TEXT, "EXPRTOKEN_NODETYPE_TEXT");
+ fTokenNames.put(EXPRTOKEN_NODETYPE_PI, "EXPRTOKEN_NODETYPE_PI");
+ fTokenNames.put(EXPRTOKEN_NODETYPE_NODE, "EXPRTOKEN_NODETYPE_NODE");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_AND, "EXPRTOKEN_OPERATOR_AND");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_OR, "EXPRTOKEN_OPERATOR_OR");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_MOD, "EXPRTOKEN_OPERATOR_MOD");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_DIV, "EXPRTOKEN_OPERATOR_DIV");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_MULT, "EXPRTOKEN_OPERATOR_MULT");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_SLASH, "EXPRTOKEN_OPERATOR_SLASH");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_DOUBLE_SLASH, "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_UNION, "EXPRTOKEN_OPERATOR_UNION");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_PLUS, "EXPRTOKEN_OPERATOR_PLUS");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_MINUS, "EXPRTOKEN_OPERATOR_MINUS");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_EQUAL, "EXPRTOKEN_OPERATOR_EQUAL");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_NOT_EQUAL, "EXPRTOKEN_OPERATOR_NOT_EQUAL");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_LESS, "EXPRTOKEN_OPERATOR_LESS");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_LESS_EQUAL, "EXPRTOKEN_OPERATOR_LESS_EQUAL");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER, "EXPRTOKEN_OPERATOR_GREATER");
+ fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER_EQUAL, "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
+ fTokenNames.put(EXPRTOKEN_FUNCTION_NAME, "EXPRTOKEN_FUNCTION_NAME");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR, "EXPRTOKEN_AXISNAME_ANCESTOR");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF, "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_ATTRIBUTE, "EXPRTOKEN_AXISNAME_ATTRIBUTE");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_CHILD, "EXPRTOKEN_AXISNAME_CHILD");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT, "EXPRTOKEN_AXISNAME_DESCENDANT");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF, "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING, "EXPRTOKEN_AXISNAME_FOLLOWING");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING, "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_NAMESPACE, "EXPRTOKEN_AXISNAME_NAMESPACE");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_PARENT, "EXPRTOKEN_AXISNAME_PARENT");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING, "EXPRTOKEN_AXISNAME_PRECEDING");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING, "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
+ fTokenNames.put(EXPRTOKEN_AXISNAME_SELF, "EXPRTOKEN_AXISNAME_SELF");
+ fTokenNames.put(EXPRTOKEN_LITERAL, "EXPRTOKEN_LITERAL");
+ fTokenNames.put(EXPRTOKEN_NUMBER, "EXPRTOKEN_NUMBER");
+ fTokenNames.put(EXPRTOKEN_VARIABLE_REFERENCE, "EXPRTOKEN_VARIABLE_REFERENCE");
}
//
@@ -946,16 +947,21 @@
// }
//
public String getTokenString(int token) {
- return (String)fTokenNames.get(new Integer(token));
+ return fTokenNames.get(token);
}
public void addToken(String tokenStr) {
- Integer tokenInt = (Integer)fTokenNames.get(tokenStr);
+ Integer tokenInt = null;
+ for (Map.Entry entry : fTokenNames.entrySet()) {
+ if (entry.getValue().equals(tokenStr)) {
+ tokenInt = entry.getKey();
+ }
+ }
if (tokenInt == null) {
- tokenInt = new Integer(fTokenNames.size());
+ tokenInt = fTokenNames.size();
fTokenNames.put(tokenInt, tokenStr);
}
- addToken(tokenInt.intValue());
+ addToken(tokenInt);
}
public void addToken(int token) {
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,8 +20,9 @@
package com.sun.org.apache.xerces.internal.impl.xpath.regex;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
/**
* A regular expression parser for the XML Schema.
@@ -369,12 +370,12 @@
return c;
}
- static private Hashtable ranges = null;
- static private Hashtable ranges2 = null;
+ static private Map ranges = null;
+ static private Map ranges2 = null;
static synchronized protected RangeToken getRange(String name, boolean positive) {
if (ranges == null) {
- ranges = new Hashtable();
- ranges2 = new Hashtable();
+ ranges = new HashMap<>();
+ ranges2 = new HashMap<>();
Token tok = Token.createRange();
setupRange(tok, SPACES);
@@ -390,7 +391,7 @@
tok = Token.createRange();
setupRange(tok, LETTERS);
setupRange(tok, LETTERS_INT);
- tok.mergeRanges((Token)ranges.get("xml:isDigit"));
+ tok.mergeRanges(ranges.get("xml:isDigit"));
ranges.put("xml:isWord", tok);
ranges2.put("xml:isWord", Token.complementRanges(tok));
diff -r b5c74ec32065 -r 35dc0af3c933 src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java
--- a/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java Thu Aug 27 23:31:51 2015 +0100
+++ b/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java Tue Apr 28 15:04:23 2015 +0300
@@ -1,13 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 1999-2002,2004,2005 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
*
@@ -20,8 +20,18 @@
package com.sun.org.apache.xerces.internal.impl.xpath.regex;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.Vector;
-import java.util.Hashtable;
/**
* This class represents a node in parse tree.
@@ -583,8 +593,8 @@
}
// ------------------------------------------------------
- private final static Hashtable categories = new Hashtable();
- private final static Hashtable categories2 = new Hashtable();
+ private final static Map categories = new HashMap<>();
+ private final static Map categories2 = new HashMap<>();
private static final String[] categoryNames = {
"Cn", "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Me", "Mc", "Nd",
"Nl", "No", "Zs", "Zl", "Zp", "Cc", "Cf", null, "Co", "Cs",
@@ -820,7 +830,7 @@
//REVISIT: do we really need to support block names as in Unicode 3.1
// or we can just create all the names in IsBLOCKNAME format (XML Schema REC)?
//
- StringBuffer buffer = new StringBuffer(50);
+ StringBuilder buffer = new StringBuilder(50);
for (int i = 0; i < Token.blockNames.length; i ++) {
Token r1 = Token.createRange();
int location;
@@ -972,22 +982,17 @@
return range;
}
- static Hashtable nonxs = null;
+ static final Set nonxs = Collections.synchronizedSet(new HashSet());
/**
* This method is called by only getRange().
* So this method need not MT-safe.
*/
static protected void registerNonXS(String name) {
- if (Token.nonxs == null)
- Token.nonxs = new Hashtable();
- Token.nonxs.put(name, name);
+ Token.nonxs.add(name);
}
+
static protected boolean isRegisterNonXS(String name) {
- if (Token.nonxs == null)
- return false;
- //DEBUG
- //System.err.println("isRegisterNonXS: "+name);
- return Token.nonxs.containsKey(name);
+ return Token.nonxs.contains(name);
}
private static void setAlias(String newName, String name, boolean positive) {
@@ -1423,17 +1428,26 @@
private static final long serialVersionUID = -2568843945989489861L;
- Vector children;
+ List