obj2xmltest.java

来自「用Java写的面相对象的数据库管理系统」· Java 代码 · 共 76 行

JAVA
76
字号
// 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-2000 by SMB GmbH. All rights reserved.//// $Id: Obj2XMLTest.java,v 1.4 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.test.xml;import org.ozoneDB.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.test.*;import test.framework.*;import org.w3c.dom.Document;import javax.xml.parsers.*;import org.xml.sax.ContentHandler;import org.xml.sax.helpers.*;import org.apache.xml.serialize.*;/** * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.4 $Date: 2000/10/28 16:55:20 $ */public class Obj2XMLTest extends OzoneTestCase {        static DocumentBuilderFactory builderFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();            public static void addSuite( TestSuite suite ) {        suite.addTest( new Obj2XMLTest( "testDOM" ) );        suite.addTest( new Obj2XMLTest( "testSAX" ) );    }             public static void main( String[] args ) throws Exception {        TestSuite suite = new TestSuite();        suite.addTest( new Obj2XMLTest( "testSAX" ) );                Suite.main( args, suite );    }             public Obj2XMLTest( String name ) {        super( name );    }            public void testSAX() throws Exception {        Data data = (Data)db.createObject( DataImpl.class.getName() );        data.setup();                XMLSerializer serializer = new XMLSerializer( System.out, new OutputFormat( "xml", "UTF-8", true ) );        db.xmlForObject( data, serializer );    }             public void testDOM() throws Exception {        Data data = (Data)db.createObject( DataImpl.class.getName() );        data.setup();                DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();        Document doc = documentBuilder.newDocument();                db.xmlForObject( data, doc );        XMLSerializer serializer = new XMLSerializer( System.out, new OutputFormat( "xml", "UTF-8", true ) );        serializer.serialize( doc );    }     }

⌨️ 快捷键说明

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