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

📄 saxchunkproducer.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                            uri == null ? "" : uri,                             lName == null ? qName : lName,                            qName);                    nextNode = elem.getNextSibling();                    break;                case Node.DOCUMENT_NODE:                    depth += deep ? 0 : 1;                    contentHandler.endDocument();                    nextNode = null;                    break;                default:                    throw new IllegalStateException( "endEvents stack contains unproper value: " + nextNode );                    //break;                }                                 chunkState = ((nextNode != null) && (endEvents.peek() != null))                        ? CHUNK_STATE_NODE                        : ((nextNode = (Node)endEvents.pop()) != null)                             ? CHUNK_STATE_CLOSE                             : CHUNK_STATE_FINISH;                break;                }             default:                throw new IllegalStateException("Unsupported value in member chunkState: " + chunkState);            }        }                 if (chunkState == CHUNK_STATE_FINISH) {            chunkOutput.setEndFlag();        }     }             /**     *  This method is used for DOM nodes that don't require two SAX events.     *  i.e. every node except document and element nodes.     *  @param _node the node to convert     */    private void convertSingleEventNode(Node _node) throws SAXException {                switch (_node.getNodeType()) {        case Node.TEXT_NODE:        case Node.CDATA_SECTION_NODE:            char[] ch = _node.getNodeValue().toCharArray();            this.contentHandler.characters( ch, 0, ch.length );            break;        case Node.PROCESSING_INSTRUCTION_NODE:            this.contentHandler.processingInstruction( _node.getNodeName(), _node.getNodeValue() );            break;        case Node.ENTITY_REFERENCE_NODE:            this.contentHandler.skippedEntity( _node.getNodeName() );            break;        case Node.COMMENT_NODE:            //"Comment node can't be translated: "            break;        case Node.DOCUMENT_TYPE_NODE:            //"Document type node can't be translated: "            break;        case Node.DOCUMENT_FRAGMENT_NODE:            //"Document fragment node can't be translated: "            break;        case Node.NOTATION_NODE:            //"Notation node can't be translated: "            break;        case Node.ENTITY_NODE:            //"Entity node can't be translated: "            break;        case Node.ATTRIBUTE_NODE:            //"Standalone attribute node can't be translated: "            break;        default:            //"unknown node type or node type not supported by this method            break;        }    }             /**     *  creates a Attributes object (list of SAX attributes) containing the     *  attributes of a given DOM element node.     *  @param elem the element whose attributes shall be converted     *  @return the SAX attribute list     */    private Attributes createSAXAttributes( Element elem ) {        NamedNodeMap domAttributes = elem.getAttributes();        AttributesImpl saxAttributes = new AttributesImpl();                int length = domAttributes.getLength();                for (int i = 0; i < length; i++) {            Node node = domAttributes.item(i);            String uri = domLevel2 ? node.getNamespaceURI() : "";            String qName = node.getNodeName();            String lName = domLevel2 ? node.getLocalName() : qName;            saxAttributes.addAttribute(                    (uri == null) ? "" : uri,                    (lName == null) ? qName : lName,                    qName, "",                    node.getNodeValue());        }                 return saxAttributes;    }             // SAX ContentHandler implementation            /**     *  Received notification of the beginning of the document.     */    public final void startDocument() throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.startDocument()..." );            }                         this.contentHandler.startDocument();            this.processLevel++;            checkChunk();        }                 depth -= deep ? 0 : 1;    }             /**     *  Received notification of the end of the document.     */    public final void endDocument() throws SAXException {        depth += deep ? 0 : 1;                if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.endDocument()..." );            }                         this.contentHandler.endDocument();            this.processLevel--;            checkChunk();        }     }             /**     *  Receive notification of character data inside an element.     */    public final void characters( char[] ch, int start, int length ) throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.characters()..." );            }                         char[] characters = new char[length];            System.arraycopy( ch, start, characters, 0, length );                        this.contentHandler.characters( characters, 0, characters.length );            checkChunk();        }     }             /**     *  Receive notification of the end of an element.     */    public final void endElement( String _namespaceURI, String _localName, String _rawName ) throws SAXException {        depth = deep ? 0 : 1;                if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.endElement()..." );            }                         this.contentHandler.endElement( _namespaceURI, _localName, _rawName );            this.processLevel--;            checkChunk();        }     }             /**     *  End the scope of a prefix-URI mapping.     */    public final void endPrefixMapping( String prefix ) throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.endPrefixMapping()..." );            }                         this.contentHandler.endPrefixMapping( prefix );            checkChunk();        }     }             /**     *  Receive notification of ignorable whitespace in element content.     */    public final void ignorableWhitespace( char[] ch, int start, int length ) throws SAXException {        // ignorable whitespaces will be ignored    }             /**     *  Receive notification of a processing instruction.     */    public final void processingInstruction( String target, String data ) throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.pi ..." );            }                         this.contentHandler.processingInstruction( target, data );            checkChunk();        }     }             /**     *  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    }             /**     *  Receive notification of a skipped entity.     */    public final void skippedEntity( java.lang.String name ) throws SAXException {        if (deep || depth >= 0) {            this.contentHandler.skippedEntity( name );            checkChunk();        }     }             /**     *  Receive notification of the start of an element.     */    public final void startElement( String namespaceURI, String localName, String rawName, Attributes atts )             throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.startElement()..." );            }                         this.contentHandler.startElement( namespaceURI, localName, rawName, atts );            this.processLevel++;            checkChunk();        }                 depth -= deep ? 0 : 1;    }             /**     *  Begin the scope of a prefix-URI Namespace mapping.     */    public final void startPrefixMapping( String prefix, String uri ) throws SAXException {        if (deep || depth >= 0) {            if (debug) {                System.out.println( "SAXChunkProducer.startPrefixMapping ..." );            }                         this.contentHandler.startPrefixMapping( prefix, uri );            checkChunk();        }     }             protected final void checkChunk() {        if (this.delegate == null) {            return;        }         try {            if ((this.chunkOutput.getState() == ChunkOutputStream.STATE_OVERFLOW) || (this.processLevel == 0)) {                this.delegate.processChunk(this);                this.chunkOutput.reset();            }         } catch (Exception e) {            e.printStackTrace();            throw new RuntimeException(e.toString());        }     }     }

⌨️ 快捷键说明

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