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

📄 retrievedocument.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package test.xmldb.other;

import org.w3c.dom.Document;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.modules.XMLResource;
import org.apache.log4j.Logger;
import test.xmldb.Constants;
/**
 * @author  Per Nyfelt
 */
public class RetrieveDocument implements Constants{

    Logger logger = Logger.getLogger(RetrieveDocument.class);

    /** Creates new RetrieveDocument */
    public RetrieveDocument() {
        try {
            Class c = Class.forName(driver);

            Database database = (Database) c.newInstance(); 
            System.out.println("Registring Database " + database);
            DatabaseManager.registerDatabase(database);
            Collection col = database.getCollection(collectionURI);
            System.out.println("Got Collection " + col);
            XMLResource resource = (XMLResource) col.getResource(resourceName);
            System.out.println("Got resource " + resource + " for " + resourceName);
            
            Document doc = (Document)resource.getContentAsDOM();
            System.out.println("Retrieved the Document with root: " + doc.getDocumentElement().getTagName());
            String content = (String)resource.getContent();
            System.out.println("here's the content:\n" + content);
            col.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static void main( String args[] ) {
        new RetrieveDocument();
    }
}

⌨️ 快捷键说明

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