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

📄 xmldtdscannerimpl.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: XMLDTDScannerImpl.java,v 1.4 2005/11/03 17:54:05 jeffsuttor Exp $ * @(#)XMLDTDScannerImpl.java	1.16 05/12/07 * * 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.dtd.nonvalidating.DTDGrammar;import java.io.EOFException;import java.io.IOException;import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;import com.sun.org.apache.xerces.internal.util.SymbolTable;import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;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.xni.XMLDTDContentModelHandler;import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;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.XMLDTDScanner;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.XMLErrorReporter;import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;import com.sun.org.apache.xerces.internal.impl.Constants;/** * This class is responsible for scanning the declarations found * in the internal and external subsets of a DTD in an XML document. * The scanner acts as the sources for the DTD information which is * communicated to the DTD handlers. * <p> * This component requires the following features and properties from the * component manager that uses it: * <ul> *  <li>http://xml.org/sax/features/validation</li> *  <li>http://apache.org/xml/features/scanner/notify-char-refs</li> *  <li>http://apache.org/xml/properties/internal/symbol-table</li> *  <li>http://apache.org/xml/properties/internal/error-reporter</li> *  <li>http://apache.org/xml/properties/internal/entity-manager</li> * </ul> * * @author Arnaud  Le Hors, IBM * @author Andy Clark, IBM * @author Glenn Marcy, IBM * @author Eric Ye, IBM * * @version $Id: XMLDTDScannerImpl.java,v 1.4 2005/11/03 17:54:05 jeffsuttor Exp $ */public class XMLDTDScannerImplextends XMLScannerimplements XMLDTDScanner, XMLComponent, XMLEntityHandler {        //    // Constants    //        // scanner states        /** Scanner state: end of input. */    protected static final int SCANNER_STATE_END_OF_INPUT = 0;        /** Scanner state: text declaration. */    protected static final int SCANNER_STATE_TEXT_DECL = 1;        /** Scanner state: markup declaration. */    protected static final int SCANNER_STATE_MARKUP_DECL = 2;        // recognized features and properties        /** Recognized features. */    private static final String[] RECOGNIZED_FEATURES = {        VALIDATION,        NOTIFY_CHAR_REFS,    };        /** Feature defaults. */    private static final Boolean[] FEATURE_DEFAULTS = {        null,        Boolean.FALSE,    };        /** 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,    };        // debugging        /** Debug scanner state. */    private static final boolean DEBUG_SCANNER_STATE = false;        //    // Data    //        // handlers        /** DTD handler. */    public XMLDTDHandler fDTDHandler = null;        /** DTD content model handler. */    protected XMLDTDContentModelHandler fDTDContentModelHandler;        // state        /** Scanner state. */    protected int fScannerState;        /** Standalone. */    protected boolean fStandalone;        /** Seen external DTD. */    protected boolean fSeenExternalDTD;        /** Seen external parameter entity. */    protected boolean fSeenExternalPE;        // private data        /** Start DTD called. */    private boolean fStartDTDCalled;        /** Default attribute */    private XMLAttributesImpl fAttributes = new XMLAttributesImpl();        /**     * Stack of content operators (either '|' or ',') in children     * content.     */    private int[] fContentStack = new int[5];        /** Size of content stack. */    private int fContentDepth;        /** Parameter entity stack to check well-formedness. */    private int[] fPEStack = new int[5];            /** Parameter entity stack to report start/end entity calls. */    private boolean[] fPEReport = new boolean[5];        /** Number of opened parameter entities. */    private int fPEDepth;        /** Markup depth. */    private int fMarkUpDepth;        /** Number of opened external entities. */    private int fExtEntityDepth;        /** Number of opened include sections. */    private int fIncludeSectDepth;        // temporary variables        /** Array of 3 strings. */    private String[] fStrings = new String[3];        /** String. */    private XMLString fString = new XMLString();        /** String buffer. */    private XMLStringBuffer fStringBuffer = new XMLStringBuffer();        /** String buffer. */    private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();        /** Literal text. */    private XMLString fLiteral = new XMLString();        /** Literal text. */    private XMLString fLiteral2 = new XMLString();        /** Enumeration values. */    private String[] fEnumeration = new String[5];        /** Enumeration values count. */    private int fEnumerationCount;        /** Ignore conditional section buffer. */    private XMLStringBuffer fIgnoreConditionalBuffer = new XMLStringBuffer(128);        /** Object contains grammar information for a non-validaing parser. */    DTDGrammar nvGrammarInfo = null;        boolean nonValidatingMode = false;    //    // Constructors    //        /** Default constructor. */    public XMLDTDScannerImpl() {    } // <init>()        /** Constructor for he use of non-XMLComponentManagers. */    public XMLDTDScannerImpl(SymbolTable symbolTable,            XMLErrorReporter errorReporter, XMLEntityManager entityManager) {        fSymbolTable = symbolTable;        fErrorReporter = errorReporter;        fEntityManager = entityManager;        entityManager.setProperty(SYMBOL_TABLE, fSymbolTable);    }        //    // XMLDTDScanner methods    //        /**     * Sets the input source.     *     * @param inputSource The input source or null.     *     * @throws IOException Thrown on i/o error.     */    public void setInputSource(XMLInputSource inputSource) throws IOException {        if (inputSource == null) {            // no system id was available            if (fDTDHandler != null) {                fDTDHandler.startDTD(null, null);                fDTDHandler.endDTD(null);            }            if (nonValidatingMode){                nvGrammarInfo.startDTD(null,null);                nvGrammarInfo.endDTD(null);            }            return;        }        fEntityManager.setEntityHandler(this);        fEntityManager.startDTDEntity(inputSource);    } // setInputSource(XMLInputSource)        /**     * Scans the external subset of the document.     *     * @param complete True if the scanner should scan the document     *                 completely, pushing all events to the registered     *                 document handler. A value of false indicates that     *                 that the scanner should only scan the next portion     *                 of the document and return. A scanner instance is     *                 permitted to completely scan a document if it does     *                 not support this "pull" scanning model.     *     * @return True if there is more to scan, false otherwise.     */    public boolean scanDTDExternalSubset(boolean complete)    throws IOException, XNIException {                fEntityManager.setEntityHandler(this);        if (fScannerState == SCANNER_STATE_TEXT_DECL) {            fSeenExternalDTD = true;            boolean textDecl = scanTextDecl();            if (fScannerState == SCANNER_STATE_END_OF_INPUT) {                return false;            }            else {                // next state is markup decls regardless of whether there                // is a TextDecl or not                setScannerState(SCANNER_STATE_MARKUP_DECL);                if (textDecl && !complete) {                    return true;                }            }        }        // keep dispatching "events"        do {            if (!scanDecls(complete)) {                return false;            }        } while (complete);                // return that there is more to scan        return true;            } // scanDTDExternalSubset(boolean):boolean        /**     * Scans the internal subset of the document.     *     * @param complete True if the scanner should scan the document     *                 completely, pushing all events to the registered     *                 document handler. A value of false indicates that     *                 that the scanner should only scan the next portion     *                 of the document and return. A scanner instance is     *                 permitted to completely scan a document if it does     *                 not support this "pull" scanning model.     * @param standalone True if the document was specified as standalone.     *                   This value is important for verifying certain     *                   well-formedness constraints.     * @param hasExternalDTD True if the document has an external DTD.     *                       This allows the scanner to properly notify     *                       the handler of the end of the DTD in the     *                       absence of an external subset.     *     * @return True if there is more to scan, false otherwise.     */    public boolean scanDTDInternalSubset(boolean complete, boolean standalone,    boolean hasExternalSubset)    throws IOException, XNIException {        // reset entity scanner        //xxx:stax getText() is supposed to return only DTD internal subset        //shouldn't we record position here before we go ahead ??               fEntityScanner = (XMLEntityScanner)fEntityManager.getEntityScanner();        fEntityManager.setEntityHandler(this);        fStandalone = standalone;

⌨️ 快捷键说明

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