jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java
changeset 23955 67c850464591
parent 12457 c348e06f0e82
child 24888 2e493ac78624
equal deleted inserted replaced
23954:1161e065d446 23955:67c850464591
     1 /*
     1 /*
     2  * reserved comment block
     2  * reserved comment block
     3  * DO NOT REMOVE OR ALTER!
     3  * DO NOT REMOVE OR ALTER!
     4  */
     4  */
     5 /*
     5 /*
     6  * Copyright 2005 The Apache Software Foundation.
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  *
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * Licensed under the Apache License, Version 2.0 (the "License");
     8  * this work for additional information regarding copyright ownership.
     9  * you may not use this file except in compliance with the License.
     9  * The ASF licenses this file to You under the Apache License, Version 2.0
    10  * You may obtain a copy of the License at
    10  * (the "License"); you may not use this file except in compliance with
       
    11  * the License.  You may obtain a copy of the License at
    11  *
    12  *
    12  *      http://www.apache.org/licenses/LICENSE-2.0
    13  *      http://www.apache.org/licenses/LICENSE-2.0
    13  *
    14  *
    14  * Unless required by applicable law or agreed to in writing, software
    15  * Unless required by applicable law or agreed to in writing, software
    15  * distributed under the License is distributed on an "AS IS" BASIS,
    16  * distributed under the License is distributed on an "AS IS" BASIS,
    17  * See the License for the specific language governing permissions and
    18  * See the License for the specific language governing permissions and
    18  * limitations under the License.
    19  * limitations under the License.
    19  */
    20  */
    20 package com.sun.org.apache.xerces.internal.xpointer;
    21 package com.sun.org.apache.xerces.internal.xpointer;
    21 
    22 
    22 import java.util.Hashtable;
    23 import java.util.HashMap;
    23 
    24 
    24 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
    25 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
    25 import com.sun.org.apache.xerces.internal.util.SymbolTable;
    26 import com.sun.org.apache.xerces.internal.util.SymbolTable;
    26 import com.sun.org.apache.xerces.internal.util.XMLChar;
    27 import com.sun.org.apache.xerces.internal.util.XMLChar;
    27 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    28 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    36  * </p>
    37  * </p>
    37  *
    38  *
    38  * @xerces.internal
    39  * @xerces.internal
    39  *
    40  *
    40  * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $
    41  * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $
    41  *
       
    42  */
    42  */
    43 class ElementSchemePointer implements XPointerPart {
    43 final class ElementSchemePointer implements XPointerPart {
    44 
    44 
    45     // Fields
    45     // Fields
    46 
    46 
    47     // The Scheme Name i.e element
    47     // The Scheme Name i.e element
    48     private String fSchemeName;
    48     private String fSchemeName;
   344                 fCurrentChildSequence[fCurrentChildDepth] = fCurrentChildPosition;
   344                 fCurrentChildSequence[fCurrentChildDepth] = fCurrentChildPosition;
   345                 fCurrentChildPosition++;
   345                 fCurrentChildPosition++;
   346 
   346 
   347                 // Donot check for empty elements if the empty element is
   347                 // Donot check for empty elements if the empty element is
   348                 // a child of a found parent element
   348                 // a child of a found parent element
   349                 //if (!fIsElementFound) {
   349                 if (checkMatch()) {
   350                     if (checkMatch()) {
   350                     if (!fIsElementFound) {
   351                         fIsElementFound = true;
       
   352                         fWasOnlyEmptyElementFound = true;
   351                         fWasOnlyEmptyElementFound = true;
   353                     } else {
   352                     } else {
   354                         fIsElementFound = false;
   353                         fWasOnlyEmptyElementFound = false;
   355                     }
   354                     }
   356                 //}
   355                     fIsElementFound = true;
   357 
   356                 } else {
       
   357                     fIsElementFound = false;
       
   358                     fWasOnlyEmptyElementFound = false;
       
   359                 }
   358             }
   360             }
   359         }
   361         }
   360 
   362 
   361         return fIsElementFound;
   363         return fIsElementFound;
   362     }
   364     }
   524         // Current token position
   526         // Current token position
   525         private int fCurrentTokenIndex;
   527         private int fCurrentTokenIndex;
   526 
   528 
   527         private SymbolTable fSymbolTable;
   529         private SymbolTable fSymbolTable;
   528 
   530 
   529         private Hashtable fTokenNames = new Hashtable();
   531         private HashMap<Integer, String> fTokenNames = new HashMap<>();
   530 
   532 
   531         /**
   533         /**
   532          * Constructor
   534          * Constructor
   533          *
   535          *
   534          * @param symbolTable SymbolTable
   536          * @param symbolTable SymbolTable
   546          * Returns the token String
   548          * Returns the token String
   547          * @param token The index of the token
   549          * @param token The index of the token
   548          * @return String The token string
   550          * @return String The token string
   549          */
   551          */
   550         private String getTokenString(int token) {
   552         private String getTokenString(int token) {
   551             return (String) fTokenNames.get(new Integer(token));
   553             return fTokenNames.get(new Integer(token));
   552         }
       
   553 
       
   554         /**
       
   555          * Returns the token String
       
   556          * @param token The index of the token
       
   557          * @return String The token string
       
   558          */
       
   559         private Integer getToken(int token) {
       
   560             return (Integer) fTokenNames.get(new Integer(token));
       
   561         }
   554         }
   562 
   555 
   563         /**
   556         /**
   564          * Add the specified string as a token
   557          * Add the specified string as a token
   565          *
   558          *
   566          * @param token The token string
   559          * @param token The token string
   567          */
   560          */
   568         private void addToken(String tokenStr) {
   561         private void addToken(String tokenStr) {
   569             Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
   562             if (!fTokenNames.containsValue(tokenStr)) {
   570             if (tokenInt == null) {
   563                 Integer tokenInt = new Integer(fTokenNames.size());
   571                 tokenInt = new Integer(fTokenNames.size());
       
   572                 fTokenNames.put(tokenInt, tokenStr);
   564                 fTokenNames.put(tokenInt, tokenStr);
   573             }
   565                 addToken(tokenInt.intValue());
   574             addToken(tokenInt.intValue());
   566             }
   575         }
   567         }
   576 
   568 
   577         /**
   569         /**
   578          * Add the specified int token
   570          * Add the specified int token
   579          *
   571          *