--- old/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java 2014-04-11 16:42:15.016365509 -0700 +++ new/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java 2014-04-11 16:42:14.908366867 -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 * @@ -19,7 +20,7 @@ */ package com.sun.org.apache.xerces.internal.xpointer; -import java.util.Hashtable; +import java.util.HashMap; import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; import com.sun.org.apache.xerces.internal.util.SymbolTable; @@ -38,9 +39,8 @@ * @xerces.internal * * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ - * */ -class ElementSchemePointer implements XPointerPart { +final class ElementSchemePointer implements XPointerPart { // Fields @@ -346,15 +346,17 @@ // Donot check for empty elements if the empty element is // a child of a found parent element - //if (!fIsElementFound) { - if (checkMatch()) { - fIsElementFound = true; + if (checkMatch()) { + if (!fIsElementFound) { fWasOnlyEmptyElementFound = true; } else { - fIsElementFound = false; + fWasOnlyEmptyElementFound = false; } - //} - + fIsElementFound = true; + } else { + fIsElementFound = false; + fWasOnlyEmptyElementFound = false; + } } } @@ -526,7 +528,7 @@ private SymbolTable fSymbolTable; - private Hashtable fTokenNames = new Hashtable(); + private HashMap fTokenNames = new HashMap<>(); /** * Constructor @@ -548,16 +550,7 @@ * @return String The token string */ private String getTokenString(int token) { - return (String) fTokenNames.get(new Integer(token)); - } - - /** - * Returns the token String - * @param token The index of the token - * @return String The token string - */ - private Integer getToken(int token) { - return (Integer) fTokenNames.get(new Integer(token)); + return fTokenNames.get(new Integer(token)); } /** @@ -566,12 +559,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()); } /**