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

Print this page

        

*** 1,28 **** /* * 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 * * 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, * 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.xpointer; ! import java.util.Hashtable; ! import java.util.Vector; import com.sun.org.apache.xerces.internal.impl.Constants; 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; --- 1,30 ---- /* * reserved comment block * DO NOT REMOVE OR ALTER! */ /* ! * 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, * 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.xpointer; ! 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; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.util.XMLChar;
*** 30,39 **** --- 32,42 ---- import com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler; import com.sun.org.apache.xerces.internal.xinclude.XIncludeNamespaceSupport; 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; import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
*** 62,73 **** */ public final class XPointerHandler extends XIncludeHandler implements XPointerProcessor { // Fields ! // A Vector of XPointerParts ! protected Vector fXPointerParts = null; // The current XPointerPart protected XPointerPart fXPointerPart = null; // Has the fXPointerPart resolved successfully --- 65,76 ---- */ public final class XPointerHandler extends XIncludeHandler implements XPointerProcessor { // Fields ! // An ArrayList of XPointerParts ! protected ArrayList<XPointerPart> fXPointerParts = null; // The current XPointerPart protected XPointerPart fXPointerPart = null; // Has the fXPointerPart resolved successfully
*** 100,124 **** * */ public XPointerHandler() { super(); ! fXPointerParts = new Vector(); fSymbolTable = new SymbolTable(); } public XPointerHandler(SymbolTable symbolTable, XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) { super(); ! fXPointerParts = new Vector(); fSymbolTable = symbolTable; fErrorHandler = errorHandler; fXPointerErrorReporter = errorReporter; //fErrorReporter = errorReporter; // The XInclude ErrorReporter } // ************************************************************************ // Implementation of the XPointerProcessor interface. // ************************************************************************ /** --- 103,131 ---- * */ public XPointerHandler() { super(); ! fXPointerParts = new ArrayList<>(); fSymbolTable = new SymbolTable(); } public XPointerHandler(SymbolTable symbolTable, XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) { super(); ! 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. // ************************************************************************ /**
*** 298,308 **** // for each element, attempt to resolve it against each pointer part // in the XPointer expression until a matching element is found. for (int i = 0; i < fXPointerParts.size(); i++) { ! fXPointerPart = (XPointerPart) fXPointerParts.get(i); if (fXPointerPart.resolveXPointer(element, attributes, augs, event)) { fFoundMatchingPtrPart = true; resolved = true; --- 305,315 ---- // for each element, attempt to resolve it against each pointer part // in the XPointer expression until a matching element is found. for (int i = 0; i < fXPointerParts.size(); i++) { ! fXPointerPart = fXPointerParts.get(i); if (fXPointerPart.resolveXPointer(element, attributes, augs, event)) { fFoundMatchingPtrPart = true; resolved = true;
*** 428,442 **** initErrorReporter(); } /** ! * Returns a Vector of XPointerPart objects * ! * @return A Vector of XPointerPart objects. */ ! public Vector getPointerParts() { return fXPointerParts; } /** * List of XPointer Framework tokens. --- 435,449 ---- initErrorReporter(); } /** ! * Returns an ArrayList of XPointerPart objects * ! * @return An ArrayList of XPointerPart objects. */ ! public ArrayList<XPointerPart> getPointerParts() { return fXPointerParts; } /** * List of XPointer Framework tokens.
*** 478,488 **** // Current token position private int fCurrentTokenIndex; private SymbolTable fSymbolTable; ! private Hashtable fTokenNames = new Hashtable(); /** * Constructor * * @param symbolTable SymbolTable --- 485,495 ---- // Current token position private int fCurrentTokenIndex; private SymbolTable fSymbolTable; ! private HashMap<Integer, String> fTokenNames = new HashMap<>(); /** * Constructor * * @param symbolTable SymbolTable
*** 506,531 **** * 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)); } /** * 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()); fTokenNames.put(tokenInt, tokenStr); - } addToken(tokenInt.intValue()); } /** * Add the specified int token * * @param token The int specifying the token --- 513,537 ---- * Returns the token String * @param token The index of the token * @return String The token string */ private String getTokenString(int token) { ! return fTokenNames.get(new Integer(token)); } /** * Add the specified string as a token * * @param token The token string */ private void addToken(String tokenStr) { ! 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