src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java

Print this page

        

@@ -1,15 +1,16 @@
 /*
  * reserved comment block
  * 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
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,

@@ -17,11 +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.HashMap;
 
 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
 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.xni.Augmentations;

@@ -36,13 +37,12 @@
  * </p>
  *
  * @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
 
     // The Scheme Name i.e element
     private String fSchemeName;

@@ -344,19 +344,21 @@
                 fCurrentChildSequence[fCurrentChildDepth] = fCurrentChildPosition;
                 fCurrentChildPosition++;
 
                 // Donot check for empty elements if the empty element is
                 // a child of a found parent element
-                //if (!fIsElementFound) {
                     if (checkMatch()) {
-                        fIsElementFound = true;
+                    if (!fIsElementFound) {
                         fWasOnlyEmptyElementFound = true;
                     } else {
+                        fWasOnlyEmptyElementFound = false;
+                    }
+                    fIsElementFound = true;
+                } else {
                         fIsElementFound = false;
+                    fWasOnlyEmptyElementFound = false;
                     }
-                //}
-
             }
         }
 
         return fIsElementFound;
     }

@@ -524,11 +526,11 @@
         // Current token position
         private int fCurrentTokenIndex;
 
         private SymbolTable fSymbolTable;
 
-        private Hashtable fTokenNames = new Hashtable();
+        private HashMap<Integer, String> fTokenNames = new HashMap<>();
 
         /**
          * Constructor
          *
          * @param symbolTable SymbolTable

@@ -546,35 +548,25 @@
          * Returns the token String
          * @param token The index of the token
          * @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));
         }
 
         /**
          * Add the specified string as a token
          *
          * @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());
         }
+        }
 
         /**
          * Add the specified int token
          *
          * @param token The int specifying the token