< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java

Print this page
rev 903 : 8153781: Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET

*** 1,29 **** /* ! * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. */ /* ! * 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.impl; - - import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; import com.sun.org.apache.xerces.internal.impl.io.UCSReader; import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; import com.sun.org.apache.xerces.internal.util.EncodingMap; --- 1,28 ---- /* ! * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* ! * 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.impl; import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; import com.sun.org.apache.xerces.internal.impl.io.UCSReader; import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; import com.sun.org.apache.xerces.internal.util.EncodingMap;
*** 42,53 **** import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Locale; - import java.util.Vector; /** * Implements the entity scanner methods. * * @author Neeraj Bajaj, Sun Microsystems --- 41,52 ---- import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; + import java.util.ArrayList; import java.util.Locale; /** * Implements the entity scanner methods. * * @author Neeraj Bajaj, Sun Microsystems
*** 56,81 **** * @author K.Venugopal Sun Microsystems * */ public class XMLEntityScanner implements XMLLocator { ! ! protected Entity.ScannedEntity fCurrentEntity = null ; protected int fBufferSize = XMLEntityManager.DEFAULT_BUFFER_SIZE; ! protected XMLEntityManager fEntityManager ; /** Security manager. */ protected XMLSecurityManager fSecurityManager = null; /** Limit analyzer. */ protected XMLLimitAnalyzer fLimitAnalyzer = null; /** Debug switching readers for encodings. */ private static final boolean DEBUG_ENCODINGS = false; /** Listeners which should know when load is being called */ ! private Vector listeners = new Vector(); private static final boolean [] VALID_NAMES = new boolean[127]; /** * Debug printing of buffer. This debugging flag works best when you --- 55,80 ---- * @author K.Venugopal Sun Microsystems * */ public class XMLEntityScanner implements XMLLocator { ! protected Entity.ScannedEntity fCurrentEntity = null; protected int fBufferSize = XMLEntityManager.DEFAULT_BUFFER_SIZE; ! protected XMLEntityManager fEntityManager; /** Security manager. */ protected XMLSecurityManager fSecurityManager = null; /** Limit analyzer. */ protected XMLLimitAnalyzer fLimitAnalyzer = null; /** Debug switching readers for encodings. */ private static final boolean DEBUG_ENCODINGS = false; + /** Listeners which should know when load is being called */ ! private ArrayList<XMLBufferListener> listeners = new ArrayList<>(); private static final boolean [] VALID_NAMES = new boolean[127]; /** * Debug printing of buffer. This debugging flag works best when you
*** 138,150 **** VALID_NAMES[45]=true; VALID_NAMES[46]=true; VALID_NAMES[58]=true; VALID_NAMES[95]=true; } ! // SAPJVM: Remember, that the XML version has explicitly been set, // so that XMLStreamReader.getVersion() can find that out. ! boolean xmlVersionSetExplicitly = false; // // Constructors // /** Default constructor. */ --- 137,151 ---- VALID_NAMES[45]=true; VALID_NAMES[46]=true; VALID_NAMES[58]=true; VALID_NAMES[95]=true; } ! ! // Remember, that the XML version has explicitly been set, // so that XMLStreamReader.getVersion() can find that out. ! protected boolean xmlVersionSetExplicitly = false; ! // // Constructors // /** Default constructor. */
*** 255,265 **** * in an XML or text declaration. * * @param xmlVersion the XML version of the current entity */ public final void setXMLVersion(String xmlVersion) { ! xmlVersionSetExplicitly = true; // SAPJVM fCurrentEntity.xmlVersion = xmlVersion; } // setXMLVersion(String) /** set the instance of current scanned entity. --- 256,266 ---- * in an XML or text declaration. * * @param xmlVersion the XML version of the current entity */ public final void setXMLVersion(String xmlVersion) { ! xmlVersionSetExplicitly = true; fCurrentEntity.xmlVersion = xmlVersion; } // setXMLVersion(String) /** set the instance of current scanned entity.
*** 544,555 **** load(0, true, true); } // scan character int c = fCurrentEntity.ch[fCurrentEntity.position++]; ! if (c == '\n' || ! (c == '\r' && isExternal)) { fCurrentEntity.lineNumber++; fCurrentEntity.columnNumber = 1; if (fCurrentEntity.position == fCurrentEntity.count) { invokeListeners(1); fCurrentEntity.ch[0] = (char)c; --- 545,555 ---- load(0, true, true); } // scan character int c = fCurrentEntity.ch[fCurrentEntity.position++]; ! if (c == '\n' || (c == '\r' && isExternal)) { fCurrentEntity.lineNumber++; fCurrentEntity.columnNumber = 1; if (fCurrentEntity.position == fCurrentEntity.count) { invokeListeners(1); fCurrentEntity.ch[0] = (char)c;
*** 951,961 **** // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true, true); } else if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(0); fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1]; load(1, false, false); fCurrentEntity.position = 0; } --- 951,961 ---- // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true, true); } else if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(1); fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1]; load(1, false, false); fCurrentEntity.position = 0; }
*** 1103,1113 **** } // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true, true); } else if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(0); fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1]; load(1, false, false); fCurrentEntity.position = 0; } --- 1103,1113 ---- } // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true, true); } else if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(1); fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1]; load(1, false, false); fCurrentEntity.position = 0; }
*** 1254,1265 **** * Scans a range of character data up to the specified delimiter, * setting the fields of the XMLString structure, appropriately. * <p> * <strong>Note:</strong> The characters are consumed. * <p> ! * <strong>Note:</strong> This assumes that the length of the delimiter ! * and that the delimiter contains at least one character. * <p> * <strong>Note:</strong> This method does not guarantee to return * the longest run of character data. This method may return before * the delimiter due to reaching the end of the input buffer or any * other reason. --- 1254,1265 ---- * Scans a range of character data up to the specified delimiter, * setting the fields of the XMLString structure, appropriately. * <p> * <strong>Note:</strong> The characters are consumed. * <p> ! * <strong>Note:</strong> This assumes that the delimiter contains at ! * least one character. * <p> * <strong>Note:</strong> This method does not guarantee to return * the longest run of character data. This method may return before * the delimiter due to reaching the end of the input buffer or any * other reason.
*** 1434,1444 **** System.out.println(" -> " + done); } } while (!done); return !done; ! } // scanData(String,XMLString) /** * Skips a character appearing immediately on the input. * <p> * <strong>Note:</strong> The character is consumed only if it matches --- 1434,1444 ---- System.out.println(" -> " + done); } } while (!done); return !done; ! } // scanData(String, XMLStringBuffer) /** * Skips a character appearing immediately on the input. * <p> * <strong>Note:</strong> The character is consumed only if it matches
*** 1556,1566 **** // handle newlines if (c == '\n' || (isExternal && c == '\r')) { fCurrentEntity.lineNumber++; fCurrentEntity.columnNumber = 1; if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(0); fCurrentEntity.ch[0] = (char)c; entityChanged = load(1, true, false); if (!entityChanged){ // the load change the position to be 1, // need to restore it when entity not changed --- 1556,1566 ---- // handle newlines if (c == '\n' || (isExternal && c == '\r')) { fCurrentEntity.lineNumber++; fCurrentEntity.columnNumber = 1; if (fCurrentEntity.position == fCurrentEntity.count - 1) { ! invokeListeners(1); fCurrentEntity.ch[0] = (char)c; entityChanged = load(1, true, false); if (!entityChanged){ // the load change the position to be 1, // need to restore it when entity not changed
*** 1725,1736 **** public boolean skipString(char [] s) throws IOException { final int length = s.length; //first make sure that required capacity is avaible if(arrangeCapacity(length, false)){ ! int beforeSkip = fCurrentEntity.position ; ! int afterSkip = fCurrentEntity.position + length ; if(DEBUG_SKIP_STRING){ System.out.println("skipString,length = " + new String(s) + "," + length); System.out.println("skipString,length = " + new String(s) + "," + length); } --- 1725,1735 ---- public boolean skipString(char [] s) throws IOException { final int length = s.length; //first make sure that required capacity is avaible if(arrangeCapacity(length, false)){ ! int beforeSkip = fCurrentEntity.position; if(DEBUG_SKIP_STRING){ System.out.println("skipString,length = " + new String(s) + "," + length); System.out.println("skipString,length = " + new String(s) + "," + length); }
*** 2105,2126 **** * Registers the listener object and provides callback. * @param listener listener to which call back should be provided when scanner buffer * is being changed. */ public void registerListener(XMLBufferListener listener) { ! if(!listeners.contains(listener)) listeners.add(listener); } /** * * @param loadPos Starting position from which new data is being loaded into scanner buffer. */ public void invokeListeners(int loadPos){ ! for(int i=0;i<listeners.size();i++){ ! XMLBufferListener listener =(XMLBufferListener) listeners.get(i); ! listener.refresh(loadPos); } } /** * Skips space characters appearing immediately on the input that would --- 2104,2125 ---- * Registers the listener object and provides callback. * @param listener listener to which call back should be provided when scanner buffer * is being changed. */ public void registerListener(XMLBufferListener listener) { ! if (!listeners.contains(listener)) { listeners.add(listener); + } } /** * * @param loadPos Starting position from which new data is being loaded into scanner buffer. */ public void invokeListeners(int loadPos){ ! for (int i=0; i<listeners.size(); i++) { ! listeners.get(i).refresh(loadPos); } } /** * Skips space characters appearing immediately on the input that would
< prev index next >