--- old/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java 2014-04-11 16:42:16.316349166 -0700 +++ new/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java 2014-04-11 16:42:16.208350524 -0700 @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 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 * @@ -17,10 +18,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.sun.org.apache.xerces.internal.xpointer; -import java.util.Hashtable; -import java.util.Vector; +import java.util.ArrayList; +import java.util.HashMap; import com.sun.org.apache.xerces.internal.impl.Constants; import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; @@ -32,6 +34,7 @@ import com.sun.org.apache.xerces.internal.xni.Augmentations; import com.sun.org.apache.xerces.internal.xni.QName; import com.sun.org.apache.xerces.internal.xni.XMLAttributes; +import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler; import com.sun.org.apache.xerces.internal.xni.XMLString; import com.sun.org.apache.xerces.internal.xni.XNIException; import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; @@ -64,8 +67,8 @@ XPointerProcessor { // Fields - // A Vector of XPointerParts - protected Vector fXPointerParts = null; + // An ArrayList of XPointerParts + protected ArrayList fXPointerParts = null; // The current XPointerPart protected XPointerPart fXPointerPart = null; @@ -102,7 +105,7 @@ public XPointerHandler() { super(); - fXPointerParts = new Vector(); + fXPointerParts = new ArrayList<>(); fSymbolTable = new SymbolTable(); } @@ -110,13 +113,17 @@ XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) { super(); - fXPointerParts = new Vector(); + fXPointerParts = new ArrayList<>(); fSymbolTable = symbolTable; fErrorHandler = errorHandler; fXPointerErrorReporter = errorReporter; //fErrorReporter = errorReporter; // The XInclude ErrorReporter } + public void setDocumentHandler(XMLDocumentHandler handler) { + fDocumentHandler = handler; + } + // ************************************************************************ // Implementation of the XPointerProcessor interface. // ************************************************************************ @@ -300,7 +307,7 @@ // in the XPointer expression until a matching element is found. for (int i = 0; i < fXPointerParts.size(); i++) { - fXPointerPart = (XPointerPart) fXPointerParts.get(i); + fXPointerPart = fXPointerParts.get(i); if (fXPointerPart.resolveXPointer(element, attributes, augs, event)) { @@ -430,11 +437,11 @@ } /** - * Returns a Vector of XPointerPart objects + * Returns an ArrayList of XPointerPart objects * - * @return A Vector of XPointerPart objects. + * @return An ArrayList of XPointerPart objects. */ - public Vector getPointerParts() { + public ArrayList getPointerParts() { return fXPointerParts; } @@ -480,7 +487,7 @@ private SymbolTable fSymbolTable; - private Hashtable fTokenNames = new Hashtable(); + private HashMap fTokenNames = new HashMap<>(); /** * Constructor @@ -508,7 +515,7 @@ * @return String The token string */ private String getTokenString(int token) { - return (String) fTokenNames.get(new Integer(token)); + return fTokenNames.get(new Integer(token)); } /** @@ -517,12 +524,11 @@ * @param token The token string */ private void addToken(String tokenStr) { - Integer tokenInt = (Integer) fTokenNames.get(tokenStr); - if (tokenInt == null) { - tokenInt = new Integer(fTokenNames.size()); + if (!fTokenNames.containsValue(tokenStr)) { + Integer tokenInt = new Integer(fTokenNames.size()); fTokenNames.put(tokenInt, tokenStr); + addToken(tokenInt.intValue()); } - addToken(tokenInt.intValue()); } /**