⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldocumentfragmentscannerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * The contents of this file are subject to the terms * of the Common Development and Distribution License * (the "License").  You may not use this file except * in compliance with the License. * * You can obtain a copy of the license at * https://jaxp.dev.java.net/CDDLv1.0.html. * See the License for the specific language governing * permissions and limitations under the License. * * When distributing Covered Code, include this CDDL * HEADER in each file and include the License file at * https://jaxp.dev.java.net/CDDLv1.0.html * If applicable add the following below this CDDL HEADER * with the fields enclosed by brackets "[]" replaced with * your own identifying information: Portions Copyright * [year] [name of copyright owner] *//* * $Id: XMLDocumentFragmentScannerImpl.java,v 1.13 2007/05/09 15:23:31 ndw Exp $ * @(#)XMLDocumentFragmentScannerImpl.java	1.24 08/03/28 * * Copyright 2005 Sun Microsystems, Inc. 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;import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;import java.io.EOFException;import java.io.IOException;import javax.xml.stream.XMLInputFactory;import javax.xml.stream.events.XMLEvent;import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;import com.sun.org.apache.xerces.internal.util.XMLAttributesIteratorImpl;import com.sun.org.apache.xerces.internal.util.XMLChar;import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;import com.sun.org.apache.xerces.internal.util.XMLSymbols;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.XMLResourceIdentifier;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.XMLComponent;import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;import com.sun.org.apache.xerces.internal.xni.Augmentations;import com.sun.org.apache.xerces.internal.impl.Constants;import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;import com.sun.org.apache.xerces.internal.util.SecurityManager;import com.sun.org.apache.xerces.internal.util.NamespaceSupport;import com.sun.org.apache.xerces.internal.xni.NamespaceContext;import javax.xml.stream.XMLStreamConstants;import javax.xml.stream.events.XMLEvent;/** * * This class is responsible for scanning the structure and content * of document fragments. * * This class has been modified as per the new design which is more suited to * efficiently build pull parser. Lot of improvements have been done and * the code has been added to support stax functionality/features. * * @author Neeraj Bajaj SUN Microsystems * @author K.Venugopal SUN Microsystems * @author Glenn Marcy, IBM * @author Andy Clark, IBM * @author Arnaud  Le Hors, IBM * @author Eric Ye, IBM * @author Sunitha Reddy, SUN Microsystems * @version $Id: XMLDocumentFragmentScannerImpl.java,v 1.13 2007/05/09 15:23:31 ndw Exp $ * */public class XMLDocumentFragmentScannerImpl        extends XMLScanner        implements XMLDocumentScanner, XMLComponent, XMLEntityHandler, XMLBufferListener {        //    // Constants    //        protected int fElementAttributeLimit;        /** External subset resolver. **/    protected ExternalSubsetResolver fExternalSubsetResolver;        // scanner states        //XXX this should be divided into more states.    /** Scanner state: start of markup. */    protected static final int SCANNER_STATE_START_OF_MARKUP = 21;        /** Scanner state: content. */    protected static final int SCANNER_STATE_CONTENT = 22;        /** Scanner state: processing instruction. */    protected static final int SCANNER_STATE_PI = 23;        /** Scanner state: DOCTYPE. */    protected static final int SCANNER_STATE_DOCTYPE = 24;        /** Scanner state: XML Declaration */    protected static final int SCANNER_STATE_XML_DECL = 25;        /** Scanner state: root element. */    protected static final int SCANNER_STATE_ROOT_ELEMENT = 26;        /** Scanner state: comment. */    protected static final int SCANNER_STATE_COMMENT = 27;        /** Scanner state: reference. */    protected static final int SCANNER_STATE_REFERENCE = 28;        // <book type="hard"> reading attribute name 'type'    protected static final int SCANNER_STATE_ATTRIBUTE = 29;        // <book type="hard"> //reading attribute value.    protected static final int SCANNER_STATE_ATTRIBUTE_VALUE = 30;        /** Scanner state: trailing misc. USED BY DOCUMENT_SCANNER_IMPL*/    //protected static final int SCANNER_STATE_TRAILING_MISC = 32;        /** Scanner state: end of input. */    protected static final int SCANNER_STATE_END_OF_INPUT = 33;        /** Scanner state: terminated. */    protected static final int SCANNER_STATE_TERMINATED = 34;        /** Scanner state: CDATA section. */    protected static final int SCANNER_STATE_CDATA = 35;        /** Scanner state: Text declaration. */    protected static final int SCANNER_STATE_TEXT_DECL = 36;        /** Scanner state: Text declaration. */    protected static final int SCANNER_STATE_CHARACTER_DATA = 37;        //<book type="hard">foo</book>    protected static final int SCANNER_STATE_START_ELEMENT_TAG = 38;        //<book type="hard">foo</book> reading </book>    protected static final int SCANNER_STATE_END_ELEMENT_TAG = 39;        protected static final int SCANNER_STATE_CHAR_REFERENCE = 40;    protected static final int SCANNER_STATE_BUILT_IN_REFS = 41;        // feature identifiers            /** Feature identifier: notify built-in refereces. */    protected static final String NOTIFY_BUILTIN_REFS =            Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_BUILTIN_REFS_FEATURE;        /** Property identifier: entity resolver. */    protected static final String ENTITY_RESOLVER =            Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;            // recognized features and properties        /** Recognized features. */    private static final String[] RECOGNIZED_FEATURES = {                NAMESPACES,                VALIDATION,                NOTIFY_BUILTIN_REFS,                NOTIFY_CHAR_REFS,                Constants.STAX_REPORT_CDATA_EVENT                    };        /** Feature defaults. */    private static final Boolean[] FEATURE_DEFAULTS = {                Boolean.TRUE,                null,                Boolean.FALSE,                Boolean.FALSE,                Boolean.TRUE    };        /** Recognized properties. */    private static final String[] RECOGNIZED_PROPERTIES = {        SYMBOL_TABLE,                ERROR_REPORTER,                ENTITY_MANAGER,    };        /** Property defaults. */    private static final Object[] PROPERTY_DEFAULTS = {                null,                null,                null,    };        protected static final char [] cdata = {'[','C','D','A','T','A','['};    protected static final char [] xmlDecl = {'<','?','x','m','l'};    protected static final char [] endTag = {'<','/'};    // debugging        /** Debug scanner state. */    private static final boolean DEBUG_SCANNER_STATE = false;        /** Debug driver. */    private static final boolean DEBUG_DISPATCHER = false;        /** Debug content driver scanning. */    protected static final boolean DEBUG_START_END_ELEMENT = false;             /** Debug driver next */    protected static final boolean DEBUG_NEXT = false ;        /** Debug driver next */    protected static final boolean DEBUG = false;    protected static final boolean DEBUG_COALESCE = false;    //    // Data    //        // protected data        /** Document handler. */    protected XMLDocumentHandler fDocumentHandler;    protected int fScannerLastState ;        /** Entity Storage */    protected XMLEntityStorage fEntityStore;        /** Entity stack. */    protected int[] fEntityStack = new int[4];        /** Markup depth. */    protected int fMarkupDepth;        //is the element empty    protected boolean fEmptyElement ;        //track if we are reading attributes, this is usefule while    //there is a callback    protected boolean fReadingAttributes = false;        /** Scanner state. */    protected int fScannerState;        /** SubScanner state: inside scanContent method. */    protected boolean fInScanContent = false;    protected boolean fLastSectionWasCData = false;    protected boolean fLastSectionWasEntityReference = false;    protected boolean fLastSectionWasCharacterData = false;                /** has external dtd */    protected boolean fHasExternalDTD;        /** Standalone. */    protected boolean fStandalone;    protected String fVersion;        // element information        /** Current element. */    protected QName fCurrentElement;        /** Element stack. */    protected ElementStack fElementStack = new ElementStack();    protected ElementStack2 fElementStack2 = new ElementStack2();        // other info        /** Document system identifier.     * REVISIT:  So what's this used for?  - NG     * protected String fDocumentSystemId;     ******/        protected String fPITarget ;        //xxx do we need to create an extra XMLString object... look for using fTempString for collecting all the data values    protected XMLString fPIData  = new XMLString();        // features            /** Notify built-in references. */    protected boolean fNotifyBuiltInRefs = false;        //STAX related properties    //defaultValues.    protected boolean fReplaceEntityReferences = true;    protected boolean fSupportExternalEntities = false;    protected boolean fReportCdataEvent = false ;    protected boolean fIsCoalesce = false ;    protected String fDeclaredEncoding =  null;    /** Disallow doctype declaration. */    protected boolean fDisallowDoctype = false;        // drivers        /** Active driver. */    protected Driver fDriver;        /** Content driver. */    protected Driver fContentDriver = createContentDriver();        // temporary variables        /** Element QName. */    protected QName fElementQName = new QName();        /** Attribute QName. */    protected QName fAttributeQName = new QName();        /**     * CHANGED: Using XMLAttributesIteratorImpl instead of XMLAttributesImpl. This class     * implements Iterator interface so we can directly give Attributes in the form of     * iterator.     */    protected XMLAttributesIteratorImpl fAttributes = new XMLAttributesIteratorImpl();            /** String. */    protected XMLString fTempString = new XMLString();        /** String. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -