📄 dtdgenerator.java
字号:
package org.mandarax.zkb.framework;
/*
* Copyright (C) 1999-2004 Jens Dietrich (mailto:mandarax@jbdietrich.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
/**
* Utility class that generates the DTD for an instance of GenericDriver.
* @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
* @version 3.4 <7 March 05>
* @version 3.4 <7 March 05>
* @since 2.2
*/
public class DTDGenerator {
/**
* Generate the DTD for a driver.
* @param driver a driver
* @param out a print stream
*/
public static void generateDTD(GenericDriver driver,PrintStream out) throws IOException {
List adapters = driver.getAdapters();
StringBuffer buf = new StringBuffer();
for (int i=0;i<adapters.size();i++) {
((Adapter)adapters.get(i)).printDTD(buf);
}
out.println(buf.toString());
}
/**
* Generate the DTD for a driver.
* @param driver a driver
*/
public static void generateDTD(GenericDriver driver) throws IOException {
PrintStream out = new PrintStream(new FileOutputStream(getFile4DTD(driver)));
generateDTD(driver,out);
out.close();
}
/**
* Run the program for the class ZKBDriver_1_0, output to console.
*/
public static void main(String[] args) throws Exception {
GenericDriver driver = new ZKBDriver_1_0();
generateDTD(driver);
System.out.println("DTD written to " + getFile4DTD(driver));
driver = new ZKBDriver_1_1();
generateDTD(driver);
System.out.println("DTD written to " + getFile4DTD(driver));
driver = new ZKBDriver_2_0();
generateDTD(driver);
System.out.println("DTD written to " + getFile4DTD(driver));
System.exit(0);
}
/**
* Get a local dtd file fr a driver.
* @param driver the driver
* @return a driver name
*/
private static String getFile4DTD(GenericDriver driver) {
return "dtd/"+driver.getName()+".dtd";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -