--- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java 2015-09-30 14:27:40.212414415 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java 2015-09-30 14:27:40.092408447 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -392,6 +392,24 @@ } /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + // no-op + return false; + } + + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + // no-op + return false; + } + + /** * Sets the document handler on the last component in the pipeline * to receive information about the document. * --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2015-09-30 14:27:40.696438489 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2015-09-30 14:27:40.544430930 -0700 @@ -1,13 +1,14 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * 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 + * 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 * @@ -18,7 +19,6 @@ * limitations under the License. */ - package com.sun.org.apache.xerces.internal.impl; import com.sun.xml.internal.stream.XMLBufferListener; @@ -403,6 +403,9 @@ protected boolean fAdd = false ; protected boolean fSkip = false; + //indicates whether the parsing process should be stopped + private boolean stopProcess = false; + /** Reusable Augmentations. */ private Augmentations fTempAugmentations = null; // @@ -507,9 +510,11 @@ throw new InternalError("processing event: " + event); } - //System.out.println("here in before calling next"); + + if (stopProcess) { + break; + } event = next(); - //System.out.println("here in after calling next"); } while (event!=XMLStreamConstants.END_DOCUMENT && complete); if(event == XMLStreamConstants.END_DOCUMENT) { @@ -521,7 +526,31 @@ } // scanDocument(boolean):boolean + /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + return stopProcess = true; + } + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + //resume only if the process was stopped. + if (stopProcess) { + stopProcess = false; + try { + scanDocument(true); + return true; + } catch (IOException | XNIException ex) { + //can not resume the parsing process, do nothing. + } + } + return false; + } public com.sun.org.apache.xerces.internal.xni.QName getElementQName(){ if(fScannerLastState == XMLEvent.END_ELEMENT){ @@ -655,6 +684,7 @@ fShouldSkip = false; fAdd = false; fSkip = false; + stopProcess = false; fEntityStore = fEntityManager.getEntityStore(); dtdGrammarUtil = null; --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java 2015-09-30 14:27:41.220464550 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java 2015-09-30 14:27:41.036455399 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2000-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 * @@ -347,6 +347,16 @@ xmlReader.parse(is); } + @Override + public boolean stop() { + return xmlReader.stop(); + } + + @Override + public boolean resume() { + return xmlReader.resume(); + } + public Schema getSchema() { return grammar; } --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java 2015-09-30 14:27:41.592483053 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java 2015-09-30 14:27:41.472477085 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001-2004 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 * @@ -581,5 +581,21 @@ return super.checkFeature(featureId); } // checkFeature(String) - + /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } + + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } } // class BasicParserConfiguration --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java 2015-09-30 14:27:41.976502153 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java 2015-09-30 14:27:41.868496781 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -894,6 +894,20 @@ } // parse(boolean):boolean + /** + * Stops the parsing process. + */ + public boolean stop() { + return fCurrentScanner.stop(); + } + + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + public boolean resume() { + return fCurrentScanner.resume(); + } + /** * Returns the state of a feature. * --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java 2015-09-30 14:27:42.396523042 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java 2015-09-30 14:27:42.288517669 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2004 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 * @@ -48,7 +48,6 @@ import com.sun.org.apache.xerces.internal.util.FeatureState; import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings; import com.sun.org.apache.xerces.internal.util.PropertyState; -import com.sun.org.apache.xerces.internal.util.Status; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler; @@ -759,154 +758,172 @@ } // parse(boolean):boolean - /** - * Returns the state of a feature. - * - * @param featureId The feature identifier. - * @return true if the feature is supported - * - * @throws XMLConfigurationException Thrown for configuration error. - * In general, components should - * only throw this exception if - * it is really - * a critical error. - */ - public FeatureState getFeatureState(String featureId) - throws XMLConfigurationException { - // make this feature special - if (featureId.equals(PARSER_SETTINGS)){ - return FeatureState.is(fConfigUpdated); - } - return super.getFeatureState(featureId); + /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } - } // getFeature(String):boolean + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } - /** - * Set the state of a feature. - * - * Set the state of any feature in a SAX2 parser. The parser - * might not recognize the feature, and if it does recognize - * it, it might not be able to fulfill the request. - * - * @param featureId The unique identifier (URI) of the feature. - * @param state The requested state of the feature (true or false). - * - * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the - * requested feature is not known. - */ - public void setFeature(String featureId, boolean state) - throws XMLConfigurationException { - fConfigUpdated = true; - // forward to every XML 1.0 component - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.setFeature(featureId, state); - } - // forward it to common components - count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.setFeature(featureId, state); - } + /** + * Returns the state of a feature. + * + * @param featureId The feature identifier. + * @return true if the feature is supported + * + * @throws XMLConfigurationException Thrown for configuration error. + * In general, components should + * only throw this exception if + * it is really + * a critical error. + */ + public FeatureState getFeatureState(String featureId) + throws XMLConfigurationException { + // make this feature special + if (featureId.equals(PARSER_SETTINGS)){ + return FeatureState.is(fConfigUpdated); + } + return super.getFeatureState(featureId); - // forward to every XML 1.1 component - count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - try{ - c.setFeature(featureId, state); - } - catch (Exception e){ - // no op - } - } - // save state if noone "objects" - super.setFeature(featureId, state); + } // getFeature(String):boolean - } // setFeature(String,boolean) + /** + * Set the state of a feature. + * + * Set the state of any feature in a SAX2 parser. The parser + * might not recognize the feature, and if it does recognize + * it, it might not be able to fulfill the request. + * + * @param featureId The unique identifier (URI) of the feature. + * @param state The requested state of the feature (true or false). + * + * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the + * requested feature is not known. + */ + public void setFeature(String featureId, boolean state) + throws XMLConfigurationException { + fConfigUpdated = true; + // forward to every XML 1.0 component + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.setFeature(featureId, state); + } + // forward it to common components + count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.setFeature(featureId, state); + } - /** - * setProperty - * - * @param propertyId - * @param value - */ - public void setProperty(String propertyId, Object value) - throws XMLConfigurationException { - fConfigUpdated = true; - // forward to every XML 1.0 component - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.setProperty(propertyId, value); - } - // forward it to every common Component - count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.setProperty(propertyId, value); - } - // forward it to every XML 1.1 component - count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - try{ - c.setProperty(propertyId, value); - } - catch (Exception e){ - // ignore it - } - } + // forward to every XML 1.1 component + count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + try{ + c.setFeature(featureId, state); + } + catch (Exception e){ + // no op + } + } + // save state if noone "objects" + super.setFeature(featureId, state); - // store value if noone "objects" - super.setProperty(propertyId, value); + } // setFeature(String,boolean) - } // setProperty(String,Object) + /** + * setProperty + * + * @param propertyId + * @param value + */ + public void setProperty(String propertyId, Object value) + throws XMLConfigurationException { + fConfigUpdated = true; + // forward to every XML 1.0 component + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.setProperty(propertyId, value); + } + // forward it to every common Component + count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.setProperty(propertyId, value); + } + // forward it to every XML 1.1 component + count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + try{ + c.setProperty(propertyId, value); + } + catch (Exception e){ + // ignore it + } + } + // store value if noone "objects" + super.setProperty(propertyId, value); - /** Returns the locale. */ - public Locale getLocale() { - return fLocale; - } // getLocale():Locale + } // setProperty(String,Object) - /** - * reset all XML 1.0 components before parsing and namespace context - */ - protected void reset() throws XNIException { - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.reset(this); - } - } // reset() + /** Returns the locale. */ + public Locale getLocale() { + return fLocale; + } // getLocale():Locale - /** - * reset all common components before parsing - */ - protected void resetCommon() throws XNIException { - // reset common components - int count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.reset(this); - } + /** + * reset all XML 1.0 components before parsing and namespace context + */ + protected void reset() throws XNIException { + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.reset(this); + } - } // resetCommon() + } // reset() - /** - * reset all components before parsing and namespace context - */ - protected void resetXML11() throws XNIException { - // reset every component - int count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - c.reset(this); - } + /** + * reset all common components before parsing + */ + protected void resetCommon() throws XNIException { + // reset common components + int count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.reset(this); + } + + } // resetCommon() + + /** + * reset all components before parsing and namespace context + */ + protected void resetXML11() throws XNIException { + // reset every component + int count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + c.reset(this); + } - } // resetXML11() + } // resetXML11() /** * Configures the XML 1.1 pipeline. @@ -956,14 +973,14 @@ fLastComponent = fXML11NSDTDValidator; } else { - // create components - if (fXML11DocScanner == null) { - // non namespace document pipeline - fXML11DocScanner = new XML11DocumentScannerImpl(); - addXML11Component(fXML11DocScanner); - fXML11DTDValidator = new XML11DTDValidator(); - addXML11Component(fXML11DTDValidator); - } + // create components + if (fXML11DocScanner == null) { + // non namespace document pipeline + fXML11DocScanner = new XML11DocumentScannerImpl(); + addXML11Component(fXML11DocScanner); + fXML11DTDValidator = new XML11DTDValidator(); + addXML11Component(fXML11DTDValidator); + } if (fCurrentScanner != fXML11DocScanner) { fCurrentScanner = fXML11DocScanner; setProperty(DOCUMENT_SCANNER, fXML11DocScanner); --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java 2015-09-30 14:27:42.764541346 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java 2015-09-30 14:27:42.660536173 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2004 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 * @@ -42,7 +42,6 @@ import com.sun.org.apache.xerces.internal.util.FeatureState; import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings; import com.sun.org.apache.xerces.internal.util.PropertyState; -import com.sun.org.apache.xerces.internal.util.Status; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler; @@ -685,155 +684,173 @@ } // parse(boolean):boolean - /** - * Returns the state of a feature. - * - * @param featureId The feature identifier. - * @return true if the feature is supported - * - * @throws XMLConfigurationException Thrown for configuration error. - * In general, components should - * only throw this exception if - * it is really - * a critical error. - */ - public FeatureState getFeatureState(String featureId) - throws XMLConfigurationException { - // make this feature special - if (featureId.equals(PARSER_SETTINGS)){ - return FeatureState.is(fConfigUpdated); - } - return super.getFeatureState(featureId); + /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } - } // getFeature(String):boolean + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + //no-op. this feature is implemented in the specific SAX parser. + return false; + } - /** - * Set the state of a feature. - * - * Set the state of any feature in a SAX2 parser. The parser - * might not recognize the feature, and if it does recognize - * it, it might not be able to fulfill the request. - * - * @param featureId The unique identifier (URI) of the feature. - * @param state The requested state of the feature (true or false). - * - * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the - * requested feature is not known. - */ - public void setFeature(String featureId, boolean state) - throws XMLConfigurationException { - fConfigUpdated = true; - // forward to every XML 1.0 component - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.setFeature(featureId, state); - } - // forward it to common components - count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.setFeature(featureId, state); - } + /** + * Returns the state of a feature. + * + * @param featureId The feature identifier. + * @return true if the feature is supported + * + * @throws XMLConfigurationException Thrown for configuration error. + * In general, components should + * only throw this exception if + * it is really + * a critical error. + */ + public FeatureState getFeatureState(String featureId) + throws XMLConfigurationException { + // make this feature special + if (featureId.equals(PARSER_SETTINGS)){ + return FeatureState.is(fConfigUpdated); + } + return super.getFeatureState(featureId); - // forward to every XML 1.1 component - count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - try{ - c.setFeature(featureId, state); - } - catch (Exception e){ - // no op - } - } - // save state if noone "objects" - super.setFeature(featureId, state); + } // getFeature(String):boolean - } // setFeature(String,boolean) + /** + * Set the state of a feature. + * + * Set the state of any feature in a SAX2 parser. The parser + * might not recognize the feature, and if it does recognize + * it, it might not be able to fulfill the request. + * + * @param featureId The unique identifier (URI) of the feature. + * @param state The requested state of the feature (true or false). + * + * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the + * requested feature is not known. + */ + public void setFeature(String featureId, boolean state) + throws XMLConfigurationException { + fConfigUpdated = true; + // forward to every XML 1.0 component + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.setFeature(featureId, state); + } + // forward it to common components + count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.setFeature(featureId, state); + } - /** - * setProperty - * - * @param propertyId - * @param value - */ - public void setProperty(String propertyId, Object value) - throws XMLConfigurationException { - fConfigUpdated = true; - // forward to every XML 1.0 component - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.setProperty(propertyId, value); - } - // forward it to every common Component - count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.setProperty(propertyId, value); - } - // forward it to every XML 1.1 component - count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - try{ - c.setProperty(propertyId, value); - } - catch (Exception e){ - // ignore it - } - } + // forward to every XML 1.1 component + count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + try{ + c.setFeature(featureId, state); + } + catch (Exception e){ + // no op + } + } + // save state if noone "objects" + super.setFeature(featureId, state); - // store value if noone "objects" - super.setProperty(propertyId, value); + } // setFeature(String,boolean) - } // setProperty(String,Object) + /** + * setProperty + * + * @param propertyId + * @param value + */ + public void setProperty(String propertyId, Object value) + throws XMLConfigurationException { + fConfigUpdated = true; + // forward to every XML 1.0 component + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.setProperty(propertyId, value); + } + // forward it to every common Component + count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.setProperty(propertyId, value); + } + // forward it to every XML 1.1 component + count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + try{ + c.setProperty(propertyId, value); + } + catch (Exception e){ + // ignore it + } + } + // store value if noone "objects" + super.setProperty(propertyId, value); - /** Returns the locale. */ - public Locale getLocale() { - return fLocale; - } // getLocale():Locale + } // setProperty(String,Object) - /** - * reset all XML 1.0 components before parsing and namespace context - */ - protected void reset() throws XNIException { - int count = fComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fComponents.get(i); - c.reset(this); - } - } // reset() + /** Returns the locale. */ + public Locale getLocale() { + return fLocale; + } // getLocale():Locale - /** - * reset all common components before parsing - */ - protected void resetCommon() throws XNIException { - // reset common components - int count = fCommonComponents.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fCommonComponents.get(i); - c.reset(this); - } + /** + * reset all XML 1.0 components before parsing and namespace context + */ + protected void reset() throws XNIException { + int count = fComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fComponents.get(i); + c.reset(this); + } - } // resetCommon() + } // reset() + /** + * reset all common components before parsing + */ + protected void resetCommon() throws XNIException { + // reset common components + int count = fCommonComponents.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fCommonComponents.get(i); + c.reset(this); + } - /** - * reset all components before parsing and namespace context - */ - protected void resetXML11() throws XNIException { - // reset every component - int count = fXML11Components.size(); - for (int i = 0; i < count; i++) { - XMLComponent c = (XMLComponent) fXML11Components.get(i); - c.reset(this); - } + } // resetCommon() + + + /** + * reset all components before parsing and namespace context + */ + protected void resetXML11() throws XNIException { + // reset every component + int count = fXML11Components.size(); + for (int i = 0; i < count; i++) { + XMLComponent c = (XMLComponent) fXML11Components.get(i); + c.reset(this); + } - } // resetXML11() + } // resetXML11() /** --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XMLParser.java 2015-09-30 14:27:43.172561639 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XMLParser.java 2015-09-30 14:27:43.068556466 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 1999-2004 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 * @@ -151,4 +151,21 @@ protected void reset() throws XNIException { } // reset() + /** + * Stops the parsing process. + * @return true if the parsing process can be stopped, false otherwise + */ + public boolean stop() { + return fConfiguration.stop(); + } + + /** + * Resumes the parsing process that has been stopped by the {@link #stop()} + * method. The method will simply return if parsing is not stopped. + * @return true if the parsing process is resumed successfully, false + * otherwise + */ + public boolean resume() { + return fConfiguration.resume(); + } } // class XMLParser --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLDocumentScanner.java 2015-09-30 14:27:43.544580141 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLDocumentScanner.java 2015-09-30 14:27:43.436574769 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001, 2002,2004 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 * @@ -72,4 +72,20 @@ throws IOException, XNIException; public int next() throws XNIException, IOException; + + + /** + * Stops the parsing process. + * @return true if the parsing process can be stopped, false otherwise + */ + public boolean stop(); + + /** + * Resumes the parsing process that has been stopped by the {@link #stop()} + * method. The method will simply return if parsing is not stopped. + * @return true if the parsing process is resumed successfully, false + * otherwise + */ + public boolean resume(); + } // interface XMLDocumentScanner --- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParserConfiguration.java 2015-09-30 14:27:43.968601230 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLParserConfiguration.java 2015-09-30 14:27:43.860595858 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001, 2002,2004 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 * @@ -250,4 +250,20 @@ /** Returns the locale. */ public Locale getLocale(); + /** + * Resumes the parsing process that has been stopped by the {@link #stop()} + * method. The method will simply return if parsing is not stopped. + * @return true if the parsing process can be stopped, false otherwise + * @see javax.xml.parsers.SAXParser + */ + public boolean stop(); + + /** + * Resumes the parsing process that has been stopped by the {@link #stop()} + * method. The method will simply return if parsing is not stopped. + * @return true if the parsing process is resumed successfully, false + * otherwise + * @see javax.xml.parsers.SAXParser + */ + public boolean resume(); } // interface XMLParserConfiguration --- old/src/java.xml/share/classes/javax/xml/parsers/SAXParser.java 2015-09-30 14:27:44.356620528 -0700 +++ new/src/java.xml/share/classes/javax/xml/parsers/SAXParser.java 2015-09-30 14:27:44.236614560 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -553,4 +553,53 @@ + "\"" ); } + + + /** + * Stops the parsing process. + *
+ * This method can be called anywhere from any event method of a SAX + * handler. Once called, it does not terminate the parsing process + * immediately. Instead, it will continue finishing and returning the + * current event, and marking the state before it stops parsing. The + * parsing state is maintained after the process is stopped. + *
+ * The event from which the method is called is considered parsed. In case + * the parsing process is subsequently resumed, it will start at the next + * event. + * + * @implSpec + * The method in the {@code javax.xml.parsers} API does nothing and returns + * false by default. Implementations that implement this method may choose + * to continue to a state for possible resumption of the operation. It is + * recommended that the current event be returned before terminating + * the parsing process. + *
+ * The method shall return true once it has notified the parser to stop
+ * parsing.
+ *
+ * @return true if the parsing process can be stopped, false otherwise
+ */
+ public boolean stop() {
+ return false;
+ }
+
+ /**
+ * Resumes the parsing process that has been stopped by the {@link #stop()}
+ * method. The method will simply return if parsing is not stopped.
+ *
+ * @implSpec
+ * The method in the {@code javax.xml.parsers} API does nothing and returns
+ * false by default. Implementations that implement this method shall
+ * check the state to determine whether the parsing process can be resumed.
+ * It shall return true after it restarted the parsing regardless of what
+ * may happen in the rest of the parsing process, that is, the return value
+ * only indicates that the parsing can be and has been resumed.
+ *
+ * @return true if the parsing process is resumed successfully, false
+ * otherwise
+ */
+ public boolean resume() {
+ return false;
+ }
}
--- /dev/null 2015-04-26 17:31:22.381138994 -0700
+++ new/test/javax/xml/jaxp/unittest/parsers/SaxParserStop.java 2015-09-30 14:27:44.624633858 -0700
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package parsers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/*
+ * @bug 8136778
+ * @summary This test verifies the stop and resume methods of the SAX parser
+ * @author Joe Wang
+ */
+public class SaxParserStop {
+ //yep, we're only displaying two records per page
+ static final int RECORD_PER_PAGE = 2;
+ SAXParser parser = null;
+ DataCollector dataCollector = null;
+
+ @Test
+ public void test() {
+ InputStream xmlFile = getClass().getResourceAsStream("SaxParserStop.xml");
+
+ int page;
+ //Get content for page 1; The parser will be started and stopped after
+ //collecting the required data.
+ page = 1;
+ List