Class MakeAdapters

java.lang.Object
   |
   +----MakeAdapters

public class MakeAdapters
extends Object
Creates event listener/adapter pairs automatically. Written because I abhor inner classes. Once created these can be used as needed. Recommend you "final" any implemented call back routines in case a subclass extends your class and tries to use the same call back.

Usage is:

 java MakeAdapters event_type event_method num_adapters [destination_package] [base_class]
 
For example:
 java MakeAdapters action Performed 1
 
creates the interface ActionPerformedOnAListener and the adapter class ActionPeformedAdapterA.

Ideally, the source is available with this page by clicking on "the source".

Version:
0.001a 9 Jul 1998
Author:
Jack Perdue j-perdue@tamu.edu si_slick@cy-net.net

Variable Index

 o ADAPTERSTRING
"Adapter"
 o DESTPACKAGE
Default package for event adapter/listeners.
 o EVENTPACKAGE
The Java AWT Event package.
 o LISTENEREXTENDS
Java base interface for event listeners.
 o LISTENERSTRING
"Listener"
 o MOTION
"Motion"
 o stupidmousemotion
Is the event a MouseMotion event? Stupid? Well, every other event in the AWT has the name FooEvent, where "Foo" also serves as the prefix to all the event's methods EXCEPT MouseMotion.
 o THELISTENER
Name for the listener ("listener").

Constructor Index

 o MakeAdapters()

Method Index

 o adapterName(String, String, String, String)
Create the adapter class's name.
 o getStream(String)
Open output stream (can optionally test for preexistence of file).
 o listenerName(String, String, String, String)
Create the listener interface's name.
 o main(String[])
Create adapter/listener pairs.
 o makeAdapter(String, String, String, String, String, String)
Creates adapter class.
 o makeListener(String, String, String, String, String, String)
Creates listener interface.
 o methodName(String, String, String, String, String)
Create the callback method's name.

Variables

 o DESTPACKAGE
 private static final String DESTPACKAGE
Default package for event adapter/listeners.

 o EVENTPACKAGE
 private static final String EVENTPACKAGE
The Java AWT Event package.

 o ADAPTERSTRING
 private static final String ADAPTERSTRING
"Adapter"

 o LISTENERSTRING
 private static final String LISTENERSTRING
"Listener"

 o THELISTENER
 private static final String THELISTENER
Name for the listener ("listener").

 o LISTENEREXTENDS
 private static final String LISTENEREXTENDS
Java base interface for event listeners.

 o stupidmousemotion
 private static boolean stupidmousemotion
Is the event a MouseMotion event? Stupid? Well, every other event in the AWT has the name FooEvent, where "Foo" also serves as the prefix to all the event's methods EXCEPT MouseMotion.

 o MOTION
 private static final String MOTION
"Motion"

Constructors

 o MakeAdapters
 public MakeAdapters()

Methods

 o main
 public static void main(String args[]) throws IOException
Create adapter/listener pairs.

Parameters:
args - Command line arguments. See usage above.
 o getStream
 private static FileOutputStream getStream(String filename)
Open output stream (can optionally test for preexistence of file).

Parameters:
filename - The file to open for output.
Returns:
A stream for the file, or optionally null if file already exist.
 o adapterName
 private static String adapterName(String baseclass,
                                   String uppereventtype,
                                   String eventmethod,
                                   String suffix)
Create the adapter class's name.

Parameters:
baseclass - Optional prefix.
uppereventtype - Event type w/first letter capitalized (eg. Action)
eventmethod - Event method (eg. Performed)
suffix - A-Z
Returns:
String for the adapter class.
 o listenerName
 private static String listenerName(String baseclass,
                                    String uppereventtype,
                                    String eventmethod,
                                    String suffix)
Create the listener interface's name.

Parameters:
baseclass - Optional prefix.
uppereventtype - Event type w/first letter capitalized (eg. Action)
eventmethod - Event method (eg. Performed)
suffix - A-Z
Returns:
String for the listener interface.
 o methodName
 private static String methodName(String baseclass,
                                  String uppereventtype,
                                  String lowereventtype,
                                  String eventmethod,
                                  String suffix)
Create the callback method's name.

Parameters:
baseclass - Optional prefix.
uppereventtype - Event type w/first letter capitalized (eg. Action)
lowereventtype - Event type w/first letter lower-case (eg. action)
eventmethod - Event method (eg. Performed)
suffix - A-Z
Returns:
String for the callback method.
 o makeAdapter
 private static void makeAdapter(String baseclass,
                                 String destpackage,
                                 String uppereventtype,
                                 String lowereventtype,
                                 String eventmethod,
                                 String suffix) throws IOException
Creates adapter class.

Parameters:
baseclass - Optional prefix.
destpackage - Destination package for class.
uppereventtype - Event type w/first letter capitalized (eg. Action)
lowereventtype - Event type w/first letter lower-case (eg. action)
eventmethod - Event method (eg. Performed)
suffix - A-Z
 o makeListener
 private static void makeListener(String baseclass,
                                  String destpackage,
                                  String uppereventtype,
                                  String lowereventtype,
                                  String eventmethod,
                                  String suffix) throws IOException
Creates listener interface.

Parameters:
baseclass - Optional prefix.
destpackage - Destination package for class.
uppereventtype - Event type w/first letter capitalized (eg. Action)
lowereventtype - Event type w/first letter lower-case (eg. action)
eventmethod - Event method (eg. Performed)
suffix - A-Z