//============================================================================== // MakeVersionInfo.java //============================================================================== package tribble.build; // System imports import java.io.IOException; import java.io.PrintWriter; import java.lang.ArrayIndexOutOfBoundsException; import java.lang.Exception; import java.lang.Package; import java.lang.String; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; /******************************************************************************* * Generates Java, C, or XML source code containing embedded build version * information. * *

* This program creates source code containing constants describing version * information for another program. It is intended to be used as part of a * makefile or batch script file used to combine one or more components into a * single executable program or library. When the source code produced by this * utility is compiled, the resulting executable object file can be combined with * the other components of the target program or library. * *

* The executable object file resulting from the compilation of the source code * produced by this utility will contain embedded string constants, reflecting * the version information specified by the command line options when this * utility was run. The embedded strings can be displayed using an appropriate * file searching utility, such as the what(1) and strings(1) * programs of Unix. * *

* The resulting Java executable .class file can also be run as a * stand-alone program. If any options are specified on the command line, the * embedded version information is displayed on the console; if no options are * specified, an AWT GUI window is displayed containing the version information. * The GUI can also be invoked if the .class file is contained within a * jar file and the class is named as the Main-Class attribute in the * manifest file of the jar file. * * *

* Usage *

* (See {@link #usage}.) * * @version $Revision: 1.6 $ $Date: 2007/07/13 04:13:17 $ * @since 2001-06-20 * @author * David R. Tribble, * david@tribble.com. *
* Copyright ©2001-2002 by David R. Tribble, all rights reserved. *
* Permission is granted to freely use and distribute this source * code provided that the original copyright and authorship notices remain * intact. * * @see AbstractVersion */ public class MakeVersionInfo { // Identification /** Revision information. */ static final String REV = "@(#)tribble/build/MakeVersionInfo.java $Revision: 1.6 $ $Date: 2007/07/13 04:13:17 $\n"; /** Version information. */ static final String VERS = "$Revision: 1.6 $".substring(11, 15).trim() + ", " + "$Date: 2007/07/13 04:13:17 $".substring(7, 17); /** Version information. */ static final String NAME = "tribble.build.MakeVersionInfo"; // Private constants //-------------------------------------------------------------------------- // Manifest constants. /** Default version number. */ private static final String DFL_VERS = "1.0"; /** Default generated class name. */ private static final String DFL_CLASS = "VersionInfo"; /** Base class that the generated class extends. */ private static final String BASE_CLASS = "tribble.build.AbstractVersion"; //-------------------------------------------------------------------------- // Exit status codes. /** Exit code: Success. */ private static final short RC_OKAY = 0; /** Exit code: Bad command usage. */ private static final short RC_USAGE = 255; //-------------------------------------------------------------------------- // Generated language types. /** Language type: (Undefined). */ private static final short LANG__UNDEF = 0; /** Language type: Java. */ private static final short LANG_JAVA = 1; /** Language type: C. */ private static final short LANG_C = 2; /** Language type: XML. */ private static final short LANG_XML = 3; // Private variables /** Output stream. */ private PrintWriter m_out = new PrintWriter(System.out, true); /** Generated language type. */ private short m_langType = LANG__UNDEF; /** Generated class name. */ private String m_class = DFL_CLASS; /** Include package information in the display. */ private boolean m_inclPkg = true; /** Generate GUI (AWT/JFC) code. */ private boolean m_genGui = true; /** Base class name that the generated class extends. */ private String m_extends = BASE_CLASS; //-------------------------------------------------------------------------- // Build information. /** Build date. */ private Date m_date = new Date(); /** Package name. */ private String m_pkg = ""; /** Component name. */ private String m_comp = ""; /** Version number. */ private String m_vers; /** Major version number. */ private int m_major = 1; /** Minor version number. */ private int m_minor = 0; /** Patch name/number. */ private String m_patch = ""; // Public static methods /*************************************************************************** * Program driver for this class. * *

* Usage *

* See {@link #usage}. * * @param args * The command line arguments. * * @see #run * * @since 1.1, 2001-07-20 */ public static void main(String args[]) { // Execute this class (new MakeVersionInfo()).run(args); System.exit(RC_OKAY); } /*************************************************************************** * Display a program usage message and punt. * *

* Usage *

* Options: *

*

*

-a name *
* Patch name or number (optional, no default). * *

*

-c name *
* Generated class name (default is {@link #DFL_CLASS}). * *

*

-n name *
* Component name (required). * *

*

-p name *
* Package name of the component. * *

*

-sa *
* Generate a stand-alone class that does not extend class * {@link AbstractVersion}. * *

*

-t lang *
* Generated source language type, where lang is one of: *
*
C *
Java *
XML *
* *

*

-v R.L *
* Component version number, consisting of a major number (R) and a * minor number (L). *
* * @since 1.1, 2001-07-20 */ public static void usage() { // Display a program usage message System.out.println("[" + NAME + ", " + VERS + "]"); System.out.println(); System.out.println( "Generate source code containing embedded build information."); System.out.println(); System.out.println("Options:"); System.out.println( " -a name Patch name/number (optional, no default)."); System.out.println( " -c name Generated class name (default is '" + DFL_CLASS + "')."); System.out.println( " -n name Component name (required)."); System.out.println( " -ng Do not generate GUI (AWT/JFC) code."); System.out.println( " -np Do not include package information in the " + "display."); System.out.println( " -p name Package name of the component (optional)."); System.out.println( " -sa Generate a stand-alone class that does not extend " + "class"); System.out.println( " '" + BASE_CLASS + "'."); System.out.println( " -t lang Generated source language type, where 'lang' is" + " one of:"); System.out.println( " C"); System.out.println( " Java"); System.out.println( " XML"); System.out.println( " -v R.L Component version number, consisting of a major" + " number ('R')"); System.out.println( " and a minor number ('L')."); // Punt System.exit(RC_USAGE); } // Public constructor methods /*************************************************************************** * Constructor. * * @since 1.1, 2001-07-20 */ public MakeVersionInfo() { // Do nothing } // Public methods /*************************************************************************** * Run this program. * * @param args * The command line arguments. * * @since 1.1, 2001-07-20 */ public void run(String[] args) { int i; // Parse the command line options i = parseOptions(args); if (i == 0) usage(); // Display the current (build) date System.err.println(m_date.toString()); // Generate the output file switch (m_langType) { case LANG_C: // Generate C source code genC(); break; case LANG_JAVA: // Generate Java source code genJava(); break; case LANG_XML: // Generate XML text genXML(); break; } // Done System.exit(RC_OKAY); } // Private static methods /*************************************************************************** * Parse the command line options, setting the appropriate member variables. * *

* Calls {@link #usage} if an improper or unsupported option argument is * encountered. * * @param args * The command line arguments. * * @return * The number of option arguments parsed. * * @since 1.1, 2001-07-20 */ private int parseOptions(String[] args) { int i = 0; // Parse the command line options try { for (i = 0; i < args.length; i++) { // Parse the next command line option if (args[i].equals("-a")) { // Patch name/number m_patch = args[++i]; } else if (args[i].equals("-c")) { // Generated class name m_class = args[++i]; } else if (args[i].equals("-n")) { // Component name m_comp = args[++i]; } else if (args[i].equals("-ng")) { // Do not generate GUI (AWT/JFC) code m_genGui = false; } else if (args[i].equals("-ngt")) { // Deprecated option, ignore } else if (args[i].equals("-np")) { // Do not include package information in the display m_inclPkg = false; } else if (args[i].equals("-p")) { // Product name m_pkg = args[++i]; } else if (args[i].equals("-sa")) { // Stand-alone generated class m_extends = null; } else if (args[i].equals("-t")) { // Generated language type i++; if (args[i].compareToIgnoreCase("C") == 0 || args[i].compareToIgnoreCase("c") == 0) m_langType = LANG_C; else if (args[i].compareToIgnoreCase("Java") == 0 || args[i].compareToIgnoreCase("j") == 0) m_langType = LANG_JAVA; else if (args[i].compareToIgnoreCase("XML") == 0 || args[i].compareToIgnoreCase("x") == 0) m_langType = LANG_XML; else { // Unsupported language type, punt throw new Exception(); } } else if (args[i].equals("-v")) { // Version number m_vers = args[++i]; } ///... else if (args[i].charAt(0) == '-') { // Unsupported option, punt throw new Exception(); } } } catch (ArrayIndexOutOfBoundsException ex) { // Bad command line option, punt usage(); } catch (Exception ex) { // Bad command line option, punt System.out.println("Unsupported option '" + args[i] + "'"); usage(); } // Check options settings and defaults if (m_vers == null) { // Version not set, assume a default m_vers = DFL_VERS; } if (m_pkg == null || m_pkg.length() == 0) { // No package specified, assume none m_inclPkg = false; } if (m_comp == null || m_comp.length() == 0) { // Missing required component name System.out.println("Missing component name (option '-n')"); usage(); } // Extract the major and minor parts from the version number { int j; int v; int len; len = m_vers.length(); // Extract the major version number part v = 0; for (j = 0; j < len; j++) { int ch; ch = m_vers.charAt(j); if (ch >= '0' && ch <= '9') v = v*10 + ch-'0'; else break; } m_major = v; // Extract the minor version number part if (j < len && m_vers.charAt(j) == '.') j++; v = 0; for ( ; j < len; j++) { int ch; ch = m_vers.charAt(j); if (ch >= '0' && ch <= '9') v = v*10 + ch-'0'; else break; } m_minor = v; } // Done return (i); } // Private methods /*************************************************************************** * Generate Java code for a class containing embedded build information. * * @since 1.1, 2001-07-20 */ private void genJava() { String date8601; String tmp; // Generate Java source date8601 = toIso8601(m_date); m_out.println("//======================================================" + "========================"); m_out.println("// " + m_class + ".java"); m_out.println("//"); m_out.println("// Generated:\t" + date8601 + " Z"); m_out.println("// By:\t\t" + NAME + ", " + VERS); m_out.println("//======================================================" + "========================"); m_out.println(); if (m_pkg == null || m_pkg.length() == 0) m_out.println("// No package"); else m_out.println("package " + m_pkg + ";"); m_out.println(); m_out.println(); m_out.println("import java.lang.Exception;"); if (m_inclPkg) m_out.println("import java.lang.Package;"); m_out.println("import java.lang.String;"); m_out.println(); m_out.println("import java.util.Date;"); m_out.println(); if (m_extends != null) { m_out.println("import " + m_extends + ";"); m_out.println(); } else if (m_genGui) { m_out.println("import java.awt.BorderLayout;"); m_out.println("import java.awt.Button;"); m_out.println("import java.awt.FlowLayout;"); m_out.println("import java.awt.Frame;"); m_out.println("import java.awt.GridLayout;"); m_out.println("import java.awt.Panel;"); m_out.println("import java.awt.TextField;"); m_out.println("import java.awt.event.ActionEvent;"); m_out.println("import java.awt.event.ActionListener;"); m_out.println("import java.awt.event.WindowEvent;"); m_out.println("import java.awt.event.WindowListener;"); m_out.println(); } m_out.println(); //---------------------------------------------------------------------- tmp = (m_patch.length() == 0 ? "" : " " + m_patch); m_out.println("/*******************************************************" + "************************"); m_out.println("* " + m_comp + ", " + m_vers + tmp + ", " + date8601.substring(0, 10) + "."); m_out.println("* "); m_out.println("* @version\t" + m_vers + tmp + ", " + date8601.substring(0, 10)); m_out.println("*/"); m_out.println(); //---------------------------------------------------------------------- m_out.println("public final class " + m_class); if (m_extends != null) m_out.println(" extends " + m_extends); else if (m_genGui) m_out.println(" implements WindowListener, ActionListener"); m_out.println("{"); //---------------------------------------------------------------------- m_out.println("// Public constants"); m_out.println(); m_out.println(" public static final String\tNAME ="); m_out.println(" \"" + m_comp + "\";"); m_out.println(); m_out.println(" public static final String\tPACKAGE ="); m_out.println(" \"" + m_pkg + "\";"); m_out.println(); m_out.println(" public static final String\tVERSION ="); m_out.println(" \"" + m_vers + "\";"); m_out.println(); m_out.println(" public static final int\tMAJOR_VERSION ="); m_out.println(" " + m_major + ";"); m_out.println(); m_out.println(" public static final int\tMINOR_VERSION ="); m_out.println(" " + m_minor + ";"); m_out.println(); m_out.println(" public static final String\tPATCH ="); m_out.println(" \"" + m_patch + "\";"); m_out.println(); m_out.println(" public static final long\tBUILD_DATE =\t\t// " + date8601 + " Z"); m_out.println(" " + m_date.getTime() + "L;"); m_out.println(); m_out.println(" public static final String\tISO_BUILD_DATE ="); m_out.println(" \"" + date8601 + "\";"); m_out.println(); ///... m_out.println(); //---------------------------------------------------------------------- m_out.println("// Private constants"); m_out.println(); m_out.println(" private static final String\tWHAT ="); m_out.println(" \"\\n\""); m_out.println(" + \"@(#)Component=" + m_comp + "\\n\""); m_out.println(" + \"@(#)Package=" + m_pkg + "\\n\""); m_out.println(" + \"@(#)Version=" + m_vers + "\\n\""); m_out.println(" + \"@(#)Patch=" + m_patch + "\\n\""); m_out.println(" + \"@(#)BuildDate=" + date8601 + " Z\\n\";"); ///... m_out.println(); m_out.println(); //---------------------------------------------------------------------- m_out.println("// Protected variables"); m_out.println(); if (m_genGui && m_extends == null) m_out.println(" protected Frame\t\tm_frame;"); else m_out.println(" // (None)"); m_out.println(); m_out.println(); //---------------------------------------------------------------------- m_out.println("// Public static methods"); m_out.println(); m_out.println(" public static void main(String[] args)"); m_out.println(" {"); m_out.println(" run(args, new " + m_class + "());"); m_out.println(" }"); m_out.println(); m_out.println(); if (m_genGui && m_extends == null) { m_out.println(" public static void run(String[] args, " + m_class + " vs)"); m_out.println(" {"); m_out.println(" if (args.length > 0)"); m_out.println(" vs.showText();"); m_out.println(" else"); m_out.println(" vs.showGui();"); m_out.println(" }"); m_out.println(); m_out.println(); } //---------------------------------------------------------------------- if (!m_genGui || m_extends != null) { m_out.println("// Public methods" + " (implements " + m_extends + ")"); m_out.println(); } m_out.println(" public " + (m_extends == null ? "static " : "") + "String getName()"); m_out.println(" {"); m_out.println(" return (NAME);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "String getPackage()"); m_out.println(" {"); m_out.println(" return (PACKAGE);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "String getVersion()"); m_out.println(" {"); m_out.println(" return (VERSION);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "int getMajor()"); m_out.println(" {"); m_out.println(" return (MAJOR_VERSION);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "int getMinor()"); m_out.println(" {"); m_out.println(" return (MINOR_VERSION);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "String getPatch()"); m_out.println(" {"); m_out.println(" return (PATCH);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "Date getBuildDate()"); m_out.println(" {"); m_out.println(" return (new Date(BUILD_DATE));"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "String getIsoBuildDate()"); m_out.println(" {"); m_out.println(" return (ISO_BUILD_DATE);"); m_out.println(" }"); m_out.println(); m_out.println(); m_out.println(" public " + (m_extends == null ? "static " : "") + "String getWhatString()"); m_out.println(" {"); m_out.println(" return (WHAT);"); m_out.println(" }"); m_out.println(); m_out.println(); //---------------------------------------------------------------------- m_out.println("// Public constructor methods"); m_out.println(); m_out.println(" public " + m_class + "()"); m_out.println(" {"); m_out.println(" // Do nothing"); m_out.println(" }"); m_out.println(); m_out.println(); //---------------------------------------------------------------------- if (m_genGui && m_extends == null) { m_out.println("// Public methods" + " (implements java.event.WindowListener)"); m_out.println(); m_out.println(" public void windowClosing(WindowEvent ev)"); m_out.println(" {"); m_out.println(" // The frame is being closed"); m_out.println(" closeMe();"); m_out.println(" }"); m_out.println(); m_out.println(" public void windowActivated(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(" public void windowClosed(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(" public void windowDeactivated(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(" public void windowDeiconified(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(" public void windowIconified(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(" public void windowOpened(WindowEvent ev)"); m_out.println(" {}"); m_out.println(); m_out.println(); m_out.println("// Public methods" + " (implements java.event.ActionListener)"); m_out.println(); m_out.println(" public void actionPerformed(ActionEvent ev)"); m_out.println(" {"); m_out.println(" // The 'close' button has been pressed"); m_out.println(" closeMe();"); m_out.println(" }"); m_out.println(); m_out.println(); } //---------------------------------------------------------------------- m_out.println("// Private methods"); m_out.println(); if (m_extends == null) { m_out.println(" private void showText()"); m_out.println(" {"); if (m_inclPkg) { m_out.println(" Package\t\tpk;"); m_out.println(); } m_out.println( " for (int i = 1+4; i < WHAT.length(); i++)"); m_out.println(" {"); m_out.println(" char ch;"); m_out.println(); m_out.println(" ch = WHAT.charAt(i);"); m_out.println(" if (ch == '\\n')"); m_out.println(" {"); m_out.println(" System.out.println();"); m_out.println(" i += 4;"); m_out.println(" }"); m_out.println(" else"); m_out.println(" System.out.print(ch);"); m_out.println(" }"); m_out.println(); if (m_inclPkg) { m_out.println( " pk = " + m_class + ".class.getPackage();"); m_out.println(" if (pk != null)"); m_out.println(" {"); m_out.println(" String\ts;"); m_out.println(); m_out.println(" s = pk.getSpecificationTitle();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"SpecificationTitle=\" + s);"); m_out.println(); m_out.println(" s = pk.getSpecificationVersion();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"SpecificationVersion=\" + s);"); m_out.println(); m_out.println(" s = pk.getSpecificationVendor();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"SpecificationVendor=\" + s);"); m_out.println(); m_out.println(" s = pk.getImplementationTitle();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"ImplementationTitle=\" + s);"); m_out.println(); m_out.println(" s = pk.getImplementationVersion();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"ImplementationVersion=\" + s);"); m_out.println(); m_out.println(" s = pk.getImplementationVendor();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" System.out.println(" + "\"ImplementationVendor=\" + s);"); m_out.println(" }"); m_out.println(); } m_out.println(" System.out.flush();"); m_out.println(" }"); m_out.println(); m_out.println(); //------------------------------------------------------------------ if (m_genGui) { m_out.println(" private void showGui()"); m_out.println(" {"); m_out.println(" Panel\t\tp;"); m_out.println(" Panel\t\tp2;"); m_out.println(" Panel\t\ttp1;"); m_out.println(" Panel\t\ttp2;"); m_out.println(" TextField\tt1;"); m_out.println(" TextField\tt2;"); m_out.println(" Button\t\tb;"); m_out.println(" int\t\tn;"); if (m_inclPkg) m_out.println(" Package\t\tpk;"); m_out.println(); m_out.println(" // Create a GUI frame/window"); m_out.println(" m_frame = new Frame(\"" + m_class + "\");"); m_out.println(); m_out.println(" // Establish window event listeners"); m_out.println(" m_frame.addWindowListener(this);"); m_out.println(); m_out.println(" // Create the main panel of the frame"); m_out.println(" p = new Panel(new BorderLayout());"); m_out.println(" m_frame.add(p);"); m_out.println(); m_out.println(" n = 0;"); m_out.println( " for (int i = 1; i < WHAT.length(); i++)"); m_out.println(" if (WHAT.charAt(i) == '\\n')"); m_out.println(" n++;"); m_out.println(); if (m_inclPkg) { m_out.println(" pk = " + m_class + ".class.getPackage();"); m_out.println(" if (pk != null)"); m_out.println(" n += 2*3;"); m_out.println(); } m_out.println(" // Create the left text field"); m_out.println(" tp1 = new Panel(new GridLayout(n, 1));"); m_out.println(" tp1.setEnabled(false);"); m_out.println(" p.add(tp1, BorderLayout.WEST);"); m_out.println(); m_out.println(" // Create the right text field"); m_out.println(" tp2 = new Panel(new GridLayout(n, 1));"); m_out.println(" tp2.setEnabled(false);"); m_out.println(" p.add(tp2, BorderLayout.CENTER);"); m_out.println(); m_out.println( " for (int i = 1; i < WHAT.length(); i++)"); m_out.println(" {"); m_out.println(" TextField\tt;"); m_out.println(" String\ts;"); m_out.println(" int\t\tj;"); m_out.println(); m_out.println(" if (WHAT.charAt(i) == '@')"); m_out.println(" i += 4;"); m_out.println( " for (j = i; i < WHAT.length(); i++)"); m_out.println(" if (WHAT.charAt(i) == '=')"); m_out.println(" break;"); m_out.println(" s = WHAT.substring(j, i);"); m_out.println(); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println(); m_out.println(" for (j = ++i; " + "i < WHAT.length(); i++)"); m_out.println(" if (WHAT.charAt(i) == '\\n')"); m_out.println(" break;"); m_out.println(" s = WHAT.substring(j, i);"); m_out.println(); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(" }"); m_out.println(); if (m_inclPkg) { m_out.println(" // Display package information"); m_out.println(" if (pk != null)"); m_out.println(" {"); m_out.println(" TextField\tt;"); m_out.println(" String\ts;"); m_out.println(" int\t\tj;"); m_out.println(); m_out.println(" s = \"SpecificationTitle\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getSpecificationTitle();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(); m_out.println(" s = \"SpecificationVersion\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getSpecificationVersion();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(); m_out.println(" s = \"SpecificationVendor\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getSpecificationVendor();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(); m_out.println(" s = \"ImplementationTitle\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getImplementationTitle();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(); m_out.println(" s = \"ImplementationVersion\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getImplementationVersion();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(); m_out.println(" s = \"ImplementationVendor\";"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp1.add(t);"); m_out.println( " s = pk.getImplementationVendor();"); m_out.println(" s = (s != null ? s : \"\");"); m_out.println(" t = new TextField(s);"); m_out.println(" t.setEditable(false);"); m_out.println(" tp2.add(t);"); m_out.println(" }"); m_out.println(); } m_out.println(" // Create the 'close' button"); m_out.println(" p2 = new Panel(new FlowLayout());"); m_out.println(" p.add(p2, BorderLayout.SOUTH);"); m_out.println(" b = new Button(\"Close\");"); //m_out.println(" //b.setMnemonic('C');"); m_out.println(" b.addActionListener(this);"); //m_out.println(" //m_frame.getRootPane().setDefaultButton(b);"); m_out.println(" p2.add(b);"); m_out.println(); m_out.println(" // Display the frame"); m_out.println(" m_frame.setSize(400, n*24+60);"); m_out.println(" m_frame.setLocation(240, 120);"); m_out.println(" m_frame.setVisible(true);"); m_out.println(" //m_frame.pack();"); m_out.println(" m_frame.show();"); m_out.println(); m_out.println(" // Wait for user to close the frame"); m_out.println(" try"); m_out.println(" {"); m_out.println(" synchronized (this)"); m_out.println(" {"); m_out.println(" wait(1*60*60*1000L);" + "\t\t// (A), wait 1 hr for a notify"); m_out.println(" }"); m_out.println(" }"); m_out.println(" catch (Exception ex)"); m_out.println(" {"); m_out.println(" // Ignore"); m_out.println(" }"); m_out.println(); m_out.println(" // Terminate"); m_out.println(" m_frame.setVisible(false);"); m_out.println(" m_frame.dispose();"); m_out.println(" }"); m_out.println(); m_out.println(); //-------------------------------------------------------------- m_out.println(" private void closeMe()"); m_out.println(" {"); m_out.println(" // Shut down the frame"); m_out.println(" synchronized (this)"); m_out.println(" {"); m_out.println(" this.notify();" + "\t\t\t// (B), thump main thread at (A)"); m_out.println(" }"); m_out.println(" }"); } } else { m_out.println(" // (None)"); } //---------------------------------------------------------------------- m_out.println("}"); m_out.println(); m_out.println("// End " + m_class + ".java"); m_out.flush(); } /*************************************************************************** * Generate C code for a class containing embedded build information. * * @since 1.1, 2001-07-20 */ private void genC() { ///... m_out.flush(); throw new Error("'-t C' option is not yet supported."); } /*************************************************************************** * Generate XML code for a class containing embedded build information. * * @since 1.1, 2001-07-20 */ private void genXML() { // Generate XML text //m_out.println(""); m_out.println(""); m_out.println(" "); m_out.println(" "); m_out.println(" "); m_out.println(""); m_out.flush(); } /*************************************************************************** * Convert a date into its corresponding ISO-8601 string form (i.e., to the * format "yyyy-mm-dd hh:mmZ"). * * @param when * A date to convert into string form. * * @return * A string of the form "yyyy-mm-dd hh:mm". * * @since 1.1, 2001-07-20 */ private String toIso8601(Date when) { SimpleDateFormat sdf; // Format a date as a string sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); sdf.setTimeZone(TimeZone.getTimeZone("")); return (sdf.format(when)); } /*************************************************************************** * Extract the year number of a date value, as a string. * * @param when * A date value. * * @return * A string of the form "yyyy". * * @since 1.1, 2001-07-20 */ private String yearOf(Date when) { SimpleDateFormat sdf; // Format a date as a string sdf = new SimpleDateFormat("yyyy"); sdf.setTimeZone(TimeZone.getTimeZone("")); return (sdf.format(when)); } } // End MakeVersionInfo.java