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

📄 saxchunkconsumer.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:


    /**
     *  Receive notification of the start of an element.
     *  Note: NamespaceImpl handling has to be revised.
     */
    public final void startElement(String _namespaceURI, String _localName, String _rawName, Attributes _atts) {
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "startElement(...)", LogWriter.DEBUG3);
        }
        Element newElem;
        if (domLevel2) {
            newElem = domFactory.createElementNS(_namespaceURI, _rawName);

            //add the attributes
            for (int i = 0; i < _atts.getLength(); i++) {
                newElem.setAttributeNS(_atts.getURI(i), _atts.getQName(i), _atts.getValue(i));
            }
        } else {
            newElem = domFactory.createElement(_rawName);

            //add the attributes
            for (int i = 0; i < _atts.getLength(); i++) {
                newElem.setAttribute(_atts.getQName(i), _atts.getValue(i));
            }

        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(newElem);
            this.startNode = newElem;
            this.currentNode = newElem;
            if (this.appendTo != null) {
                this.appendTo.appendChild(newElem);
            }
        } else {
            this.currentNode.appendChild(newElem);
            this.currentNode = newElem;
        }
        this.processLevel++;
    }


    /**
     *  Receive notification of the end of an element.
     */
    public final void endElement(String _namespaceURI, String _localName, String _rawName) {
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "endElement(...)", LogWriter.DEBUG3);
        }

        this.currentNode = this.currentNode.getParentNode();
        this.processLevel--;
    }


    /**
     *  Begin the scope of a prefix-URI NamespaceImpl mapping.
     */
    public final void startPrefixMapping(String _prefix, String _uri) {
        return;
    }


    /**
     *  End the scope of a prefix-URI mapping.
     */
    public final void endPrefixMapping(String prefix) {
        // Ozone is not yet namespace aware, so we ignore the prefix mappings
    }


    /**
     *  Receive notification of character data inside an element.
     */
    public final void characters(char[] ch, int start, int length) {

        if ((this.currentNode != null)
                && (this.currentNode.getNodeType() == Node.CDATA_SECTION_NODE)) {
            //we receive a CDATA section

            StringBuffer chars = new StringBuffer();

            chars.append(ch, start, length);
            chars.append(this.currentNode.getNodeValue());
            this.currentNode.setNodeValue(chars.toString());
        } else {
            //just normal characters
            Text textNode = this.domFactory.createTextNode(new String(ch, start, length));
            if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
                logWriter.newEntry(this, "characters(...)", LogWriter.DEBUG3);
            }

            if (this.processLevel == 0) {
                this.resultNodeList.addNode(textNode);
                this.startNode = textNode;
                this.currentNode = textNode;
                if (this.appendTo != null) {
                    this.appendTo.appendChild(textNode);
                }
            } else {
                this.currentNode.appendChild(textNode);
            }
        }
    }


    /**
     *  Receive notification of a processing instruction.
     */
    public final void processingInstruction(String _target, String _data) {
        ProcessingInstruction piNode = domFactory.createProcessingInstruction(_target, _data);
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "processingInstruction(...)", LogWriter.DEBUG3);
        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(piNode);
            this.startNode = piNode;
            this.currentNode = piNode;
            if (this.appendTo != null) {
                this.appendTo.appendChild(piNode);
            }
        } else {
            this.currentNode.appendChild(piNode);
        }
    }


    /**
     *  Receive notification of a skipped entity.
     */
    public final void skippedEntity(java.lang.String _name) {
        EntityReference erNode = domFactory.createEntityReference(_name);
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "skippedEntity(...)", LogWriter.DEBUG3);
        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(erNode);
            this.startNode = erNode;
            this.currentNode = erNode;
            if (this.appendTo != null) {
                this.appendTo.appendChild(erNode);
            }
        } else {
            this.currentNode.appendChild(erNode);
        }
    }


    /**
     *  Receive notification of ignorable whitespace in element content.
     */
    public final void ignorableWhitespace(char[] _ch, int _start, int _length) {
        Text whitespace = domFactory.createTextNode(new String(_ch, _start, _length));
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "ignorableWhitespace(...)", LogWriter.DEBUG3);
        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(whitespace);
            this.startNode = whitespace;
            this.currentNode = whitespace;
            if (this.appendTo != null) {
                this.appendTo.appendChild(whitespace);
            }
        } else {
            this.currentNode.appendChild(whitespace);
        }
    }


    /**
     *  Receive an object for locating the origin of SAX document events.
     */
    public final void setDocumentLocator(Locator locator) {
    // we don't care about the origin of the document
    }


    //
    // SAX LexicalHandler implemenation
    //


    public void comment( char[] ch, int start, int length ) throws SAXException {

        Comment commentNode = this.domFactory.createComment(new String(ch, start, length));
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "comment(...)", LogWriter.DEBUG3);
        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(commentNode);
            this.startNode = commentNode;
            this.currentNode = commentNode;
            if (this.appendTo != null) {
                this.appendTo.appendChild(commentNode);
            }
        } else {
            this.currentNode.appendChild(commentNode);
        }
    }


    public void startCDATA() throws SAXException {
        CDATASection cdata = this.domFactory.createCDATASection("");
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "startCDATA(...)", LogWriter.DEBUG3);
        }

        if (this.processLevel == 0) {
            this.resultNodeList.addNode(cdata);
            this.startNode = cdata;
            this.currentNode = cdata;
            if (this.appendTo != null) {
                this.appendTo.appendChild(cdata);
            }
        } else {
            this.currentNode.appendChild(cdata);
            this.currentNode = cdata;
        }
        this.processLevel++;
    }


    public void endCDATA() throws SAXException {
        if (logWriter.hasTarget( LogWriter.DEBUG3 )) {
            logWriter.newEntry(this, "endCDATA(...)", LogWriter.DEBUG3);
        }

        this.currentNode = this.currentNode.getParentNode();
        this.processLevel--;
    }


    public void startDTD(String name, String publicId, String systemId)
            throws SAXException {
        //FIXME(?)
        //not handled
    }


    public void endDTD() throws SAXException {
        //FIXME(?)
        //not handled
    }


    public void startEntity(String name) throws SAXException {
        //FIXME(?)
        //not handled
    }


    public void endEntity(String name) throws SAXException {
        //FIXME(?)
        //not handled
    }
}

⌨️ 快捷键说明

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