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

📄 xmldtdscannerimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        //System.out.println("state"+fScannerState);        if (fScannerState == SCANNER_STATE_TEXT_DECL) {            // call handler            if (fDTDHandler != null) {                fDTDHandler.startDTD(fEntityScanner, null);                fStartDTDCalled = true;            }                        if (nonValidatingMode){                fStartDTDCalled = true;                nvGrammarInfo.startDTD(fEntityScanner,null);            }            // set starting state for internal subset            setScannerState(SCANNER_STATE_MARKUP_DECL);        }        // keep dispatching "events"        do {            if (!scanDecls(complete)) {                // call handler                if (fDTDHandler != null && hasExternalSubset == false) {                    fDTDHandler.endDTD(null);                }                if (nonValidatingMode && hasExternalSubset == false ){                    nvGrammarInfo.endDTD(null);                }                // we're done, set starting state for external subset                setScannerState(SCANNER_STATE_TEXT_DECL);                return false;            }        } while (complete);                // return that there is more to scan        return true;            } // scanDTDInternalSubset(boolean,boolean,boolean):boolean        //    // XMLComponent methods    //        /**     * reset     *     * @param componentManager     */    public void reset(XMLComponentManager componentManager)    throws XMLConfigurationException {                super.reset(componentManager);                init();            } // reset(XMLComponentManager)        // this is made for something like XMLDTDLoader--XMLComponentManager-free operation...    public void reset() {        super.reset();        init();    }        public void reset(PropertyManager props) {        setPropertyManager(props);        super.reset(props);        init() ;        nonValidatingMode = true;        //Revisit : Create new grammar until we implement GrammarPool.        nvGrammarInfo = new DTDGrammar(fSymbolTable);            }    /**     * Returns a list of feature identifiers that are recognized by     * this component. This method may return null if no features     * are recognized by this component.     */    public String[] getRecognizedFeatures() {        return (String[])(RECOGNIZED_FEATURES.clone());    } // getRecognizedFeatures():String[]        /**     * Returns a list of property identifiers that are recognized by     * this component. This method may return null if no properties     * are recognized by this component.     */    public String[] getRecognizedProperties() {        return (String[])(RECOGNIZED_PROPERTIES.clone());    } // getRecognizedProperties():String[]        /**     * Returns the default state for a feature, or null if this     * component does not want to report a default value for this     * feature.     *     * @param featureId The feature identifier.     *     * @since Xerces 2.2.0     */    public Boolean getFeatureDefault(String featureId) {        for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {            if (RECOGNIZED_FEATURES[i].equals(featureId)) {                return FEATURE_DEFAULTS[i];            }        }        return null;    } // getFeatureDefault(String):Boolean        /**     * Returns the default state for a property, or null if this     * component does not want to report a default value for this     * property.     *     * @param propertyId The property identifier.     *     * @since Xerces 2.2.0     */    public Object getPropertyDefault(String propertyId) {        for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {            if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {                return PROPERTY_DEFAULTS[i];            }        }        return null;    } // getPropertyDefault(String):Object        //    // XMLDTDSource methods    //        /**     * setDTDHandler     *     * @param dtdHandler     */    public void setDTDHandler(XMLDTDHandler dtdHandler) {        fDTDHandler = dtdHandler;    } // setDTDHandler(XMLDTDHandler)        /**     * getDTDHandler     *     * @return the XMLDTDHandler     */    public XMLDTDHandler getDTDHandler() {        return fDTDHandler;    } // getDTDHandler():  XMLDTDHandler        //    // XMLDTDContentModelSource methods    //        /**     * setDTDContentModelHandler     *     * @param dtdContentModelHandler     */    public void setDTDContentModelHandler(XMLDTDContentModelHandler    dtdContentModelHandler) {        fDTDContentModelHandler = dtdContentModelHandler;    } // setDTDContentModelHandler        /**     * getDTDContentModelHandler     *     * @return XMLDTDContentModelHandler     */    public XMLDTDContentModelHandler getDTDContentModelHandler() {        return fDTDContentModelHandler ;    } // setDTDContentModelHandler        //    // XMLEntityHandler methods    //        /**     * This method notifies of the start of an entity. The DTD has the     * pseudo-name of "[dtd]" parameter entity names start with '%'; and     * general entities are just specified by their name.     *     * @param name     The name of the entity.     * @param identifier The resource identifier.     * @param encoding The auto-detected IANA encoding name of the entity     *                 stream. This value will be null in those situations     *                 where the entity encoding is not auto-detected (e.g.     *                 internal entities or a document entity that is     *                 parsed from a java.io.Reader).     * @param augs     Additional information that may include infoset augmentations     *     * @throws XNIException Thrown by handler to signal an error.     */    public void startEntity(String name,                             XMLResourceIdentifier identifier,                            String encoding, Augmentations augs) throws XNIException {        super.startEntity(name, identifier, encoding, augs);        boolean dtdEntity = name.equals("[dtd]");        if (dtdEntity) {            // call handler            if (fDTDHandler != null && !fStartDTDCalled ) {                fDTDHandler.startDTD(fEntityScanner, null);            }            if (fDTDHandler != null) {                fDTDHandler.startExternalSubset(identifier,null);            }            fEntityManager.startExternalSubset();            fEntityStore.startExternalSubset();            fExtEntityDepth++;        }        else if (name.charAt(0) == '%') {            pushPEStack(fMarkUpDepth, fReportEntity);            if (fEntityScanner.isExternal()) {                fExtEntityDepth++;            }        }                // call handler        if (fDTDHandler != null && !dtdEntity && fReportEntity) {            fDTDHandler.startParameterEntity(name, identifier, encoding, null);        }            } // startEntity(String,XMLResourceIdentifier,String)        /**     * This method notifies the end of an entity. The DTD has the pseudo-name     * of "[dtd]" parameter entity names start with '%'; and general entities     * are just specified by their name.     *     * @param name The name of the entity.     *     * @throws XNIException Thrown by handler to signal an error.     */    public void endEntity(String name, Augmentations augs)    throws XNIException, IOException {                super.endEntity(name, augs);                // if there is no data after the doctype        //        if (fScannerState == SCANNER_STATE_END_OF_INPUT)            return;                // Handle end of PE        boolean reportEntity = fReportEntity;        if (name.startsWith("%")) {            reportEntity = peekReportEntity();            // check well-formedness of the enity            int startMarkUpDepth = popPEStack();            // throw fatalError if this entity was incomplete and            // was a freestanding decl            if(startMarkUpDepth == 0 &&            startMarkUpDepth < fMarkUpDepth) {                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,                "ILL_FORMED_PARAMETER_ENTITY_WHEN_USED_IN_DECL",                new Object[]{ fEntityManager.fCurrentEntity.name},                XMLErrorReporter.SEVERITY_FATAL_ERROR);            }            if (startMarkUpDepth != fMarkUpDepth) {                reportEntity = false;                if (fValidation) {                    // Proper nesting of parameter entities is a Validity Constraint                    // and must not be enforced when validation is off                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,                    "ImproperDeclarationNesting",                    new Object[]{ name },                    XMLErrorReporter.SEVERITY_ERROR);                }            }            if (fEntityScanner.isExternal()) {                fExtEntityDepth--;            }        }                // call handler        boolean dtdEntity = name.equals("[dtd]");        if (fDTDHandler != null && !dtdEntity && reportEntity) {            fDTDHandler.endParameterEntity(name, null);        }                // end DTD        if (dtdEntity) {            if (fIncludeSectDepth != 0) {                reportFatalError("IncludeSectUnterminated", null);            }            fScannerState = SCANNER_STATE_END_OF_INPUT;            // call handler            fEntityManager.endExternalSubset();            fEntityStore.endExternalSubset();                        if (fDTDHandler != null) {                fDTDHandler.endExternalSubset(null);                fDTDHandler.endDTD(null);            }            fExtEntityDepth--;        }        //XML (Document Entity) is the last opened entity, however        //if for some reason DTD Scanner receives this callback        //there is something wrong (probably invalid XML), throw exception.        //or         //For standalone DTD loader, it might be the last opened entity        //and if this is the last opened entity and fMarkUpDepth != 0 or         //fIncludeSectDepth != 0 or fExtEntityDepth != 0 throw Exception        if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.LAST_ENTITY))             && ( fMarkUpDepth != 0 || fExtEntityDepth !=0 || fIncludeSectDepth != 0)){            throw new EOFException();        }    } // endEntity(String)            // helper methods        /**     * Sets the scanner state.     *     * @param state The new scanner state.     */    protected final void setScannerState(int state) {                fScannerState = state;        if (DEBUG_SCANNER_STATE) {            System.out.print("### setScannerState: ");            System.out.print(getScannerStateName(state));            //System.out.println();        }            } // setScannerState(int)        //    // Private methods    //        /** Returns the scanner state name. */    private static String getScannerStateName(int state) {                if (DEBUG_SCANNER_STATE) {            switch (state) {                case SCANNER_STATE_END_OF_INPUT: return "SCANNER_STATE_END_OF_INPUT";                case SCANNER_STATE_TEXT_DECL: return "SCANNER_STATE_TEXT_DECL";                case SCANNER_STATE_MARKUP_DECL: return "SCANNER_STATE_MARKUP_DECL";            }        }                return "??? ("+state+')';            } // getScannerStateName(int):String        protected final boolean scanningInternalSubset() {        return fExtEntityDepth == 0;    }        /**     * start a parameter entity dealing with the textdecl if there is any     *     * @param name The name of the parameter entity to start (without the '%')     * @param literal Whether this is happening within a literal     */    protected void startPE(String name, boolean literal)    throws IOException, XNIException {        int depth = fPEDepth;        String pName = "%"+name;        if (fValidation && !fEntityStore.isDeclaredEntity(pName)) {

⌨️ 快捷键说明

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