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

📄 xmlcontainer.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        } while (!cos.getEndFlag());        if (XMLContainer.debug) {            System.out.println("DOM store: store in db time: " + time + " ms");        }    }             /**     * Stores a DOM tree represented by SAX events in the datasabase. The     * newly created Nodes are appended to the Document Node of this container.     *     * @see #storeSAX(Node)     */    public ContentHandler storeSAX() throws Exception {        if (helper == null) {            throw new IllegalStateException( "Document has already been deleted." );        }         return storeSAX( null );    }         /**     *  Stores XML represented by SAX events into the database.     *  <p>The entire storage process <b>must</b> be enclosed by an     *  {@link org.ozoneDB.ExternalTransaction explicit Transaction}. This is an     *  exception to the normal case, where an implicit transaction (handled by     *  Ozone) is more appropriate. The storage process starts with the call to this     *  method and ends with the last event send to the content handler. The SAX     *  events must be properly terminated, i.e. there must be an end event for     *  for every start event, otherwise the correct storage can't be guaranteed.</p>     *     *  @param _pNode The persistent node where the stored data will be appended to.     *     *  @return the content handler which stores all XML data it recieves into the     *          database.     *     *  @throws IllegalStateException if the underlying document has already been deleted.     *  @throws IllegalStateException if the current thread has not joined a     *          {@link org.ozoneDB.ExternalTransaction transaction}.     *  @see org.ozoneDB.ExternalTransaction     *  @see org.ozoneDB.ExternalDatabase#newTransaction()     */    public ContentHandler storeSAX(Node _pNode) throws Exception {        if (helper == null) {            throw new IllegalStateException( "Document has already been deleted." );        }         // thread must have joined a transaction        if (runsExternal && ((ExternalDatabase)db).currentTransaction() == null) {            throw new IllegalStateException( "Thread must have joined a transaction!" );        }                 // this eventually blocks if there is another thread storing something already        SAXChunkConsumer consumer = helper.beginInputSequence(_pNode);                SAXChunkProducer producer = new SAXChunkProducer(this);                producer.dbConsumer = consumer;        return producer;    }             /**     *  This method is for internal use only. <b>Don't call it directly.</b>     */    public void processChunk(SAXChunkProducer _producer) throws Exception {        if (XMLContainer.debug) {            System.out.print("XMLContainer.processChunk()... ");        }                 ChunkOutputStream cos = _producer.chunkStream();        if (XMLContainer.debug) {            System.out.print("putChunk(" + cos.count + ")... ");        }                 _producer.dbConsumer = helper.putChunk(cos.toByteArray(), _producer.dbConsumer);            }         /**     * @see #extractDOM(Document, Node, Node , int)     */    public Document extractDOM( Document _domFactory ) throws Exception {        return (Document) extractDOM( _domFactory, null, null, -1 );    }    /**     * @see #extractDOM(Document, Node, Node , int)     */    public Node extractDOM( Document _domFactory, Node _pNode, Node _appendTo) throws Exception {        return extractDOM( _domFactory, _pNode, _appendTo, -1 );    }    /**     * Extracts a given DOM node and all its descendants.     *     * <p>Before calling this method the current thread <b>must</b> have joined an      * {@link org.ozoneDB.ExternalTransaction explicit Transaction}. This is an     * exception to the normal case, where an implicit transaction (handled by      * Ozone) is more appropriate.</p>     *     * <p><dl><dt>Note:</dt><dd>If possible, the corresponding      * {@link #extractSAX(ContentHandler) SAX method} should be used, because the     * performance of SAX storage is much better.</dd></dl></p>     *     * @param _domFactory The DOM Document that is used to create the extracted DOM nodes.     * @param _pNode The persistent DOM node      * @param _appendTo The transient DOM node where the extracted content will     *     will be appended to.     *  @param _depth The number of hierarchy steps that should be extracted or     *      null if the entire hierarchy should be extracted.     */    public Node extractDOM ( Document _domFactory, Node _pNode, Node _appendTo, int _depth) throws Exception {        if (helper == null) {            throw new IllegalStateException ("Document has already been deleted.");        }         // thread must have joined a transaction        if (runsExternal && ((ExternalDatabase)db).currentTransaction() == null) {            throw new IllegalStateException( "Thread must have joined a transaction!" );        }                 SAXChunkProducer producer = helper.beginOutputSequence( _pNode, _depth );        SAXChunkConsumer consumer = new SAXChunkConsumer(_domFactory, _appendTo);        ChunkOutputStream cos;        do {            producer = helper.createNextChunk( producer );            cos = producer.chunkStream();            consumer.processChunk( cos.toByteArray() );        } while (!cos.getEndFlag());                return consumer.getResultNode();    }             /**     * @see #extractSAX(ContentHandler, Node, int)     */    public void extractSAX( ContentHandler _contentHandler ) throws Exception {        extractSAX( _contentHandler, null, -1 );    }             /**     * @see #extractSAX(ContentHandler, Node , int )     */    public void extractSAX( ContentHandler _contentHandler, Node _pNode ) throws Exception {        extractSAX( _contentHandler, _pNode, -1 );    }             /**     *  Extracts a given DOM node and all its descendants.     *     *  <p>Before calling this method the current thread <b>must</b> have joined an      *  {@link org.ozoneDB.ExternalTransaction explicit Transaction}. This is an     *  exception to the normal case, where an implicit transaction (handled by      *  Ozone) is more appropriate.</p>     *     *  @param _contentHandler The ContentHandler that will receive the generated     *      SAX events.     *  @param _pNode The persistent DOM node that is the starting point, or null     *      if the entire document should be extracted.     *  @param _depth The number of hierarchy steps that should be extracted or     *      null if the entire hierarchy should be extracted.     */    public void extractSAX( ContentHandler _contentHandler, Node _pNode, int _depth ) throws Exception {                if (helper == null) {            throw new IllegalStateException( "Document has already been deleted." );        }         // thread must have joined a transaction        if (runsExternal && ((ExternalDatabase)db).currentTransaction() == null) {            throw new IllegalStateException( "Thread must have joined a transaction!" );        }         SAXChunkProducer producer = helper.beginOutputSequence( _pNode, _depth );        SAXChunkConsumer consumer = new SAXChunkConsumer( _contentHandler );        ChunkOutputStream cos;        do {            producer = helper.createNextChunk( producer );            cos = producer.chunkStream();            consumer.processChunk( cos.toByteArray() );        } while (!cos.getEndFlag());    }             public XPathQuery newXPathQuery() {        return new XPathQuery();    }             public XObject executeQuery( XPathQuery _query ) throws Exception {        return executeQuery( _query, null );    }             public XObject executeQuery( XPathQuery _query, Node _pnode ) throws Exception {        if (_query == null) {            throw new IllegalArgumentException( "_query == null." );        }         return helper.executeQuery( _query, _pnode );    }             /**     * Determines the absolute XPath for the given node.     *      * @param node The W3C DOM node whose XPath is to determine.     * @return The string representing the absolute XPath for this node.     */    public String xpathForNode( Node _pnode ) {        if (helper == null) {            throw new IllegalStateException( "Document has already been deleted." );        }         return helper.xpathForNode( _pnode );    }             public void writeExternal( ObjectOutput _out ) throws IOException {        if (runsExternal) {            throw new IllegalStateException( "XMLContainer cannot be serialized outside an ozone server." );        }         _out.writeObject( helper );    }             public void readExternal( ObjectInput _in ) throws IOException, ClassNotFoundException {        if (runsExternal) {            throw new IllegalStateException( "XMLContainer cannot be deserialized outside an ozone server." );        }         helper = (XMLContainerHelper)_in.readObject();        db = org.ozoneDB.core.Env.currentEnv().database;    }     }

⌨️ 快捷键说明

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