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

Print this page

        

*** 1,26 **** /* ! * Copyright (c) 2003, 2013, 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.xml.internal.stream.XMLBufferListener; import com.sun.xml.internal.stream.XMLEntityStorage; import com.sun.xml.internal.stream.XMLInputFactoryImpl; --- 1,26 ---- /* ! * Copyright (c) 2003, 2015, 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.xml.internal.stream.XMLBufferListener; import com.sun.xml.internal.stream.XMLEntityStorage; import com.sun.xml.internal.stream.XMLInputFactoryImpl;
*** 401,410 **** --- 401,413 ---- protected String fElementRawname ; protected boolean fShouldSkip = false; 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; // // Constructors //
*** 505,517 **** break; default : throw new InternalError("processing event: " + event); } ! //System.out.println("here in before calling next"); event = next(); - //System.out.println("here in after calling next"); } while (event!=XMLStreamConstants.END_DOCUMENT && complete); if(event == XMLStreamConstants.END_DOCUMENT) { fDocumentHandler.endDocument(null); return false; --- 508,522 ---- break; default : throw new InternalError("processing event: " + event); } ! ! if (stopProcess) { ! break; ! } event = next(); } while (event!=XMLStreamConstants.END_DOCUMENT && complete); if(event == XMLStreamConstants.END_DOCUMENT) { fDocumentHandler.endDocument(null); return false;
*** 519,529 **** --- 524,558 ---- return true; } // 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){ fElementQName.setValues(fElementStack.getLastPoppedElement()); }
*** 653,662 **** --- 682,692 ---- fInScanContent = false; //skipping algorithm fShouldSkip = false; fAdd = false; fSkip = false; + stopProcess = false; fEntityStore = fEntityManager.getEntityStore(); dtdGrammarUtil = null; if (fSecurityManager != null) {