📄 odg.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.//// $Id$package org.ozoneDB.tools.OPP;import java.io.*;import org.ozoneDB.tools.OPP.message.MessageWriter;import org.ozoneDB.tools.OPP.message.SummaryMessageWriterDecorator;import org.ozoneDB.tools.OPP.message.StdOutMessageWriter;import org.ozoneDB.tools.OPP.srcgen.ClassBuilder;import org.ozoneDB.tools.OPP.srcgen.ClassDirector;import org.ozoneDB.tools.OPP.castor.*;/** * Command line driver for the ODG tool. * * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision$Date$ */public class ODG { private static OPPBean oppBean = new OPPBean(); public static void main(String[] args) { oppBean.setGenerateFactory(false); oppBean.setGenerateProxy(false); oppBean.setGenerateOcd(true); String outputDirName = "." + File.separator; //boolean printStackTrace = false; if (args.length == 0) { printUsage(); System.exit(0); } MessageWriter genListener = new SummaryMessageWriterDecorator(new StdOutMessageWriter(false, false)); for (int argCount = 0; argCount < args.length; argCount++) { if (args[argCount].equals("-st")) { oppBean.setPrintStackTrace(true); } else if (args[argCount].equals("-version")) { System.out.println("$Id$"); System.exit(0); } else if (args[argCount].equals("-h")) { printUsage(); System.exit(0); } else if (args[argCount].startsWith("-o")) { outputDirName = args[argCount].substring(2) + File.separator; } else { if (args[argCount].startsWith("-")) { System.out.println("Unknown option '" + args[argCount] + "'!\n"); printUsage(); System.exit(0); } else { try { if (args[argCount].endsWith(".xml") || args[argCount].endsWith(".ocd")) { OzoneClassDescriptor descriptor = CDHelper.xml2Descriptor(args[argCount]); showDescriptor(descriptor); } else { genListener.info(args[argCount] + ":"); ClassBuilder builder = oppBean.createBuilder(new File(outputDirName), null, null); ClassDirector director = oppBean.createDirector(new File(outputDirName)); director.build(args[argCount], builder); } } catch (Exception e) { System.out.println("Error: " + e.toString()); e.printStackTrace(System.out); } } } } } public static void printUsage() { System.out.println("Ozone Descriptor Generator"); System.out.println("usage: [-p<pattern>] [-q] [-h] [-o<directory>] class [class]*"); System.out.println(" -p regular expression to specify update methods (not implemented)"); System.out.println(" -o out/input directory for class files and sources"); System.out.println(" -version shows version information"); System.out.println(" -h shows this help"); } protected static void showDescriptor(OzoneClassDescriptor descriptor) { System.out.println("The OzoneClassDescriptor:"); System.out.println("Name: " + descriptor.getName()); System.out.println("Desc: " + descriptor.getDescription()); System.out.println("Package: " + descriptor.getPackage()); System.out.println("Superclass: " + descriptor.getSuperclass()); System.out.println("Interfaces: "); String[] _i = descriptor.getInterface(); if (_i != null) { for (int i = 0, l = _i.length; i < l; ++i) { System.out.println(" " + _i[i]); } } System.out.println("Constructors: "); Constructors ctors = descriptor.getConstructors(); PublicConstructor[] ctor = ctors.getPublicConstructor(); for (int i = 0, l = ctor.length; i < l; ++i) { System.out.println(" - parameters: " + ctor[i].getParameter()); if (ctor[i].getDescription() != null) { System.out.println(" desc: " + ctor[i].getDescription()); } } System.out.println("Methods: "); Methods mths = descriptor.getMethods(); PublicMethod[] m = mths.getPublicMethod(); for (int i = 0, l = m.length; i < l; ++i) { System.out.println(" - name: " + m[i].getName()); System.out.println(" parameters: " + m[i].getParameter()); System.out.println(" locklevel : " + m[i].getLocklevel()); if (m[i].getDescription() != null) { System.out.println(" desc: " + m[i].getDescription()); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -