All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.tools.dip.MorphController

java.lang.Object
   |
   +----com.ibm.beans.tools.dip.MorphController

public class MorphController
extends Object
implements MorphViewListener
The MorphController class displays the Morphing UI and manages the Models of the classes to be morphed and the dips to be applied. A MorphController instance is invoked by the morph class. A MorphController instance can be invoked directly from a Frame such as the bean box.

See Also:
morph

Variable Index

 o fAdditionalClasses
The array of additional API class names.
 o fAdditionalInterfaces
The array of additional API interface names.
 o fBeanInfoRootFileName
The root part of the BeanInfo classes file name.
 o fClassesModel
Model containing the classes.
 o fClassesModelListener
Listener to tell this MorphController when more classes are added to the model
 o fClassesModelManipulator
MorphModelManipulator instance linked to fClassesModel.
 o fClassesModelSelectable
Flag indicating if the fClassesModel implements the ModelSelectable interface.
 o fCleanUpJavaFiles
Flag indicating if the .java source code of the morphed class should be deleted after a successful compilation.
 o fCompileFiles
Flag indicating if the .java source code of the morphed class should be compiled.
 o fCompileOK
Local flag indicating if the generated .java source code compiled cleanly.
 o fCreateDipSer
Flag indicating if .ser files for the dips applied to the dippable bean should be created.
 o fCustomizedDips
The hashtable used to hold the initial property settings for the pre-dips.
 o fDebugLog
The debug log messages are written to.
 o fDippableRootFileName
The root part of the dippable classes file name.
 o fDipsModel
Model containing the dips.
 o fDipsModelListener
Listener to tell this MorphController when more dips are added to the model
 o fDipsModelManipulator
MorphModelManipulator instance linked to fDipsModel.
 o fDipsModelSelectable
Flag indicating if the fDipsModel implements the ModelSelectable interface.
 o fDipsModelUpdateListener
Listener to the classes model, so that when classes are added, all dips are added to the dips model too.
 o fErrorLog
The status log messages are written to.
 o fExit
Flag indicating a System.exit() method call needs to be run when the MorphController exits.
 o fLocalSaveToJar
Local flag indicating whether processing problems will prevent this MorphController from saving the morphed class to a jar.
 o fMF
The MessageFormatter for a MorphDialog.
 o fOriginalRepositoryName
The name of the original repository which held the original class.
 o fOriginalRepositoryURL
The URL of the original repository which held the original class.
 o fSaveToJar
Flag indicating if the morphed class should be saved to a jar or repository.
 o fView
MorphView instantiation.

Constructor Index

 o MorphController(MorphView, MorphModelManipulator)
Constructs a MorphController instance.
 o MorphController(MorphView, MorphModelManipulator, MorphModelManipulator)
Constructs a MorphController instance.

Method Index

 o compile(String, String)
Compiles the file.
 o createDipSerFiles()
Creates .ser files for every pre-Dip added to the dippable bean.
 o doMorphing(String, String, boolean, String, boolean)
Morphs the class.
 o finalize()
Disposes of system resources and performs other cleanup before garbage collection.
 o getAdditionalAPIs()
Gets the list of additional APIs to be added to the dippable class.
 o getClassName()
Gets package qualified class name of the class to use while morphing.
 o getDips()
Gets the list of dips to be applied to the dippable class.
 o getDoCleanUpJavaFiles()
Gets the flag that indicates if the .java source code of the morphed class should be deleted after a successful compilation.
 o getDoCompileFiles()
Gets the flag that indicates if the .java source code of the morphed class should be compiled.
 o getDoCreateDipSer()
Gets the flag that indicates if .ser files for the dips applied to to the dippable bean should be created.
 o getDoRunExit()
Gets the flag that indicates a System.exit() method call needs to be run when the MorphController exits.
 o getDoSaveToJar()
Gets the flag that indicates if the morphed class should be saved to a jar or repository.
 o getFinalMethodNames()
Gets the list of final method names in the new dippable class that should be final methods.
 o getInterfaces(Class, Vector)
Gets the names of all the interfaces implemented by a class and puts them in a vector.
 o handleAdditionalClassSelected(MorphViewEvent)
Manages a ADDITIONAL_CLASS_SELECTED MorphViewEvent.
 o handleCancel(MorphViewEvent)
Manages a CANCEL MorphViewEvent.
 o handleClassSelected(MorphViewEvent)
Manages a CLASS_SELECTED MorphViewEvent.
 o handleDipDeselected(MorphViewEvent)
Manages a DIP_DESELECTED MorphViewEvent.
 o handleDipSelected(MorphViewEvent)
Manages a DIP_SELECTED MorphViewEvent.
 o handleFinalMethods(MorphViewEvent)
Manages a FINAL_METHODS MorphViewEvent.
 o handleLoadClassesModel(MorphViewEvent)
Manages a LOAD_CLASSES_MODEL MorphViewEvent.
 o handleLoadDipsModel(MorphViewEvent)
Manages a LOAD_DIPS_MODEL MorphViewEvent.
 o handleMorph(MorphViewEvent)
Manages a MORPH MorphViewEvent.
 o handleViewAction(MorphViewEvent)
Manages an action from the MorphView.
 o morph(String, String, boolean, String, boolean, String)
Morph the class.
 o outputErrorMessage(String)
Output the error message using a MessageFormatter object.
 o outputErrorMessage(String, String)
Output the error message using a MessageFormatter object.
 o outputErrorMessage(String, String, String)
Output the error message using a MessageFormatter object.
 o outputErrorMessageWithoutFormatter(String)
Output the error message without using a MessageFormatter object.
 o outputStatusMessage(String, String)
Output the status message using a MessageFormatter object.
 o outputStatusMessage(String, String, String)
Output the status message using a MessageFormatter object.
 o saveToJar(String, String, boolean)
Saves the morphed class to either the original or a new Jar file.
 o setDoCleanUpJavaFiles(boolean)
Sets the flag that indicates if the .java source code of the morphed class should be deleted after a successful compilation.
 o setDoCompileFiles(boolean)
Sets the flag that indicates if the .java source code of the morphed class should be compiled.
 o setDoCreateDipSer(boolean)
Sets the flag that indicates if .ser files for the dips applied to to the dippable bean should be created.
 o setDoRunExit(boolean)
Sets the flag that indicates a System.exit() method call needs to be run when the MorphController exits.
 o setDoSaveToJar(boolean)
Sets the flag that indicates if the morphed class should be saved to a jar or repository.

Variables

 o fAdditionalClasses
 protected String fAdditionalClasses[]
The array of additional API class names.

 o fAdditionalInterfaces
 protected String fAdditionalInterfaces[]
The array of additional API interface names.

 o fDipsModelListener
 protected ModelChangeListener fDipsModelListener
Listener to tell this MorphController when more dips are added to the model

 o fClassesModelListener
 protected ModelChangeListener fClassesModelListener
Listener to tell this MorphController when more classes are added to the model

 o fDipsModelUpdateListener
 protected ModelChangeListener fDipsModelUpdateListener
Listener to the classes model, so that when classes are added, all dips are added to the dips model too.

 o fView
 protected MorphView fView
MorphView instantiation. This is the GUI presented to the user.

 o fClassesModel
 protected Model fClassesModel
Model containing the classes.

 o fClassesModelManipulator
 protected MorphModelManipulator fClassesModelManipulator
MorphModelManipulator instance linked to fClassesModel.

 o fDipsModel
 protected Model fDipsModel
Model containing the dips.

 o fDipsModelManipulator
 protected MorphModelManipulator fDipsModelManipulator
MorphModelManipulator instance linked to fDipsModel.

 o fClassesModelSelectable
 protected boolean fClassesModelSelectable
Flag indicating if the fClassesModel implements the ModelSelectable interface.

 o fDipsModelSelectable
 protected boolean fDipsModelSelectable
Flag indicating if the fDipsModel implements the ModelSelectable interface.

 o fCustomizedDips
 protected Hashtable fCustomizedDips
The hashtable used to hold the initial property settings for the pre-dips.

 o fMF
 protected MessageFormatter fMF
The MessageFormatter for a MorphDialog.

 o fExit
 protected boolean fExit
Flag indicating a System.exit() method call needs to be run when the MorphController exits.

See Also:
setDoRunExit, getDoRunExit
 o fLocalSaveToJar
 protected boolean fLocalSaveToJar
Local flag indicating whether processing problems will prevent this MorphController from saving the morphed class to a jar.

 o fSaveToJar
 protected boolean fSaveToJar
Flag indicating if the morphed class should be saved to a jar or repository.

See Also:
setDoSaveToJar, getDoSaveToJar
 o fCreateDipSer
 protected boolean fCreateDipSer
Flag indicating if .ser files for the dips applied to the dippable bean should be created.

See Also:
setDoCreateDipSer, getDoCreateDipSer
 o fCompileFiles
 protected boolean fCompileFiles
Flag indicating if the .java source code of the morphed class should be compiled.

See Also:
setDoCompileFiles, getDoCompileFiles
 o fCompileOK
 protected boolean fCompileOK
Local flag indicating if the generated .java source code compiled cleanly.

 o fCleanUpJavaFiles
 protected boolean fCleanUpJavaFiles
Flag indicating if the .java source code of the morphed class should be deleted after a successful compilation.

See Also:
setDoCleanUpJavaFiles, getDoCleanUpJavaFiles
 o fErrorLog
 protected LogStream fErrorLog
The status log messages are written to.

 o fDebugLog
 protected LogStream fDebugLog
The debug log messages are written to.

 o fDippableRootFileName
 protected String fDippableRootFileName
The root part of the dippable classes file name. For example D:\src\main is the root part of D:\src\main.java.

 o fBeanInfoRootFileName
 protected String fBeanInfoRootFileName
The root part of the BeanInfo classes file name. For example D:\src\mainBeanInfo is the root part of D:\src\mainBeanInfo.java.

 o fOriginalRepositoryURL
 protected String fOriginalRepositoryURL
The URL of the original repository which held the original class.

 o fOriginalRepositoryName
 protected String fOriginalRepositoryName
The name of the original repository which held the original class.

Constructors

 o MorphController
 public MorphController(MorphView modelView,
                        MorphModelManipulator classesManipulator)
Constructs a MorphController instance. The MorphController manages all the logic between the ModelView implementation and the Models in the MorphModelManipulator instances. Because there is no seperate dipsManipulator, the copy constructor for the classesManipulator will be used to create a seperate model for the dips.

Parameters:
modelView -
The view to be presented to the user.
classesManipulator -
The MorphModelManipulator containing the model of the classes to be selected for morphing.

This parameter can be null if the user wishes to use an empty BeanBagModel instance as the Model implementation.

 o MorphController
 public MorphController(MorphView modelView,
                        MorphModelManipulator classesManipulator,
                        MorphModelManipulator dipsManipulator)
Constructs a MorphController instance. The MorphController manages all the logic between the ModelView and the Models in the MorphModelManipulators.

Parameters:
modelView -
The view to be presented to the user.
classesManipulator -
The MorphModelManipulator containing the model of the classes to be selected for morphing.

This parameter can be null if the user wishes to use an empty BeanBagModel instance as the Model implementation.

dipsManipulator -
The MorphModelManipulator containing the model of the dips to be applied for pre-dipping.

This parameter can be null if the user wishes to use an empty BeanBagModel instance as the Model implementation.

Methods

 o handleViewAction
 public void handleViewAction(MorphViewEvent evt)
Manages an action from the MorphView. This method is invoked when a change from the MorphView means action needs to be taken.

Parameters:
evt - A MorphViewEvent object describing what action is requested and providing all data necessary to handle the event.
 o handleLoadClassesModel
 protected void handleLoadClassesModel(MorphViewEvent evt)
Manages a LOAD_CLASSES_MODEL MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the LOAD_CLASSES_MODEL Action ID.
 o handleLoadDipsModel
 protected void handleLoadDipsModel(MorphViewEvent evt)
Manages a LOAD_DIPS_MODEL MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the LOAD_DIPS_MODEL Action ID.
 o handleClassSelected
 protected void handleClassSelected(MorphViewEvent evt)
Manages a CLASS_SELECTED MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the CLASS_SELECTED Action ID.
 o handleFinalMethods
 protected void handleFinalMethods(MorphViewEvent evt)
Manages a FINAL_METHODS MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the FINAL_METHODS Action ID.
 o handleDipSelected
 protected void handleDipSelected(MorphViewEvent evt)
Manages a DIP_SELECTED MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the DIP_SELECTED Action ID.
 o handleDipDeselected
 protected void handleDipDeselected(MorphViewEvent evt)
Manages a DIP_DESELECTED MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the DIP_DESELECTED Action ID.
 o handleCancel
 protected void handleCancel(MorphViewEvent evt)
Manages a CANCEL MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the CANCEL Action ID.
 o handleMorph
 protected void handleMorph(MorphViewEvent evt)
Manages a MORPH MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the MORPH Action ID.
 o handleAdditionalClassSelected
 protected void handleAdditionalClassSelected(MorphViewEvent evt)
Manages a ADDITIONAL_CLASS_SELECTED MorphViewEvent.

Parameters:
evt - The MorphViewEvent with the ADDITIONAL_CLASS_SELECTED Action ID.
 o setDoRunExit
 public void setDoRunExit(boolean state)
Sets the flag that indicates a System.exit() method call needs to be run when the MorphController exits.

Parameters:
state - true indicates the System.exit() method should be called; false otherwise.
 o getDoRunExit
 public boolean getDoRunExit()
Gets the flag that indicates a System.exit() method call needs to be run when the MorphController exits.

Returns:
true indicates the System.exit() method should be called; false otherwise.
 o setDoSaveToJar
 public void setDoSaveToJar(boolean state)
Sets the flag that indicates if the morphed class should be saved to a jar or repository.

Parameters:
state - true indicates the morphed class should be saved; false otherwise.
 o getDoSaveToJar
 public boolean getDoSaveToJar()
Gets the flag that indicates if the morphed class should be saved to a jar or repository.

Returns:
true indicates the morphed class should be saved; false otherwise.
 o setDoCreateDipSer
 public void setDoCreateDipSer(boolean state)
Sets the flag that indicates if .ser files for the dips applied to to the dippable bean should be created. This flag is only checked if the dippable bean is not saved to a jar. If the dippable bean is saved to a jar, the .ser file must be created.

Parameters:
state - true indicates the dip .ser file should be created; false otherwise.
 o getDoCreateDipSer
 public boolean getDoCreateDipSer()
Gets the flag that indicates if .ser files for the dips applied to to the dippable bean should be created. This flag is only checked if the dippable bean is not saved to a jar. If the dippable bean is saved to a jar, the .ser file must be created.

Returns:
true indicates the dip .ser file should be created; false otherwise.
 o setDoCleanUpJavaFiles
 public void setDoCleanUpJavaFiles(boolean state)
Sets the flag that indicates if the .java source code of the morphed class should be deleted after a successful compilation. If compilation is not attemped, then the .java source is not deleted, no matter what the setting of this property.

Parameters:
state - true indicates the generated .java source code should be deleted after a successful compile; false otherwise.
 o getDoCleanUpJavaFiles
 public boolean getDoCleanUpJavaFiles()
Gets the flag that indicates if the .java source code of the morphed class should be deleted after a successful compilation. If compilation is not attemped, then the .java source is not deleted, no matter what the setting of this property.

Returns:
true indicates the generated .java source code will be deleted after a successful compile; false otherwise.
 o setDoCompileFiles
 public void setDoCompileFiles(boolean state)
Sets the flag that indicates if the .java source code of the morphed class should be compiled.

Parameters:
state - true indicates the generated .java source code should be compiled; false otherwise.
 o getDoCompileFiles
 public boolean getDoCompileFiles()
Gets the flag that indicates if the .java source code of the morphed class should be compiled.

Returns:
true indicates the generated .java source code will be compiled; false otherwise.
 o getAdditionalAPIs
 protected String getAdditionalAPIs()
Gets the list of additional APIs to be added to the dippable class.

For more information, see additionalAPIs parameter in DippableGenerator

Returns:
null if no additional APIs are to be added to the new dippable class; otherwise a string with the list of additional APIs.
 o getDips
 protected String getDips()
Gets the list of dips to be applied to the dippable class.

For more information, see dips parameter in DippableGenerator

Returns:
null if no dips are to be applied to the new dippable class; otherwise a string with the list of dips.
 o getFinalMethodNames
 protected String getFinalMethodNames()
Gets the list of final method names in the new dippable class that should be final methods.

Returns:
null if no methods are to be final methods; otherwise a string with the list of method names. Method names are separated in the string by a semicolon (;).
 o getClassName
 protected String getClassName()
Gets package qualified class name of the class to use while morphing.

Returns:
null if no class is selected; otherwise return the name of the class.
 o doMorphing
 protected void doMorphing(String className,
                           String interfaceName,
                           boolean useInherit,
                           String newName,
                           boolean beanInfo)
Morphs the class.

Parameters:
className - The package qualified name of the class to morph.
interfaceName - The interface the new dippable bean should implement.
useInherit -
true means create the new dippable bean through inheritance; false means create the new dippable bean through aggregation.
newName -
A String containing a name for the new dippable bean. If null, the name of the dippable bean is be based on the className argument.

This parameter can be null.

beanInfo -
true means create a BeanInfo for the new dippable class; false means do not create a BeanInfo.
Returns:
true if morphing is successful
 o outputErrorMessageWithoutFormatter
 protected void outputErrorMessageWithoutFormatter(String msg)
Output the error message without using a MessageFormatter object.

Parameters:
msg - The error message.
 o outputErrorMessage
 protected void outputErrorMessage(String msgKey)
Output the error message using a MessageFormatter object.

Parameters:
msgKey - The string that is the key for retrieving a message from the MessageFormatter instance.
 o outputErrorMessage
 protected void outputErrorMessage(String msgKey,
                                   String msgParm)
Output the error message using a MessageFormatter object.

Parameters:
msgKey - The string that is the key for retrieving a message from the MessageFormatter instance.
msgParm - An object reference to the variable argument.
 o outputErrorMessage
 protected void outputErrorMessage(String msgKey,
                                   String msgParm1,
                                   String msgParm2)
Output the error message using a MessageFormatter object.

Parameters:
msgKey - The string that is the key for retrieving a message from the MessageFormatter instance.
msgParm1 - An object reference to the first variable argument.
msgParm2 - An object reference to the second variable argument.
 o outputStatusMessage
 protected void outputStatusMessage(String msgKey,
                                    String msgParm)
Output the status message using a MessageFormatter object.

Parameters:
msgKey - The string that is the key for retrieving a message from the MessageFormatter instance.
msgParm - An object reference to the variable argument.
 o outputStatusMessage
 protected void outputStatusMessage(String msgKey,
                                    String msgParm1,
                                    String msgParm2)
Output the status message using a MessageFormatter object.

Parameters:
msgKey - The string that is the key for retrieving a message from the MessageFormatter instance.
msgParm1 - An object reference to the first variable argument.
msgParm2 - An object reference to the second variable argument.
 o saveToJar
 protected void saveToJar(String originalClassName,
                          String newClassName,
                          boolean beanInfo)
Saves the morphed class to either the original or a new Jar file.

Parameters:
originalClassName - The name of the original, un-morphed class.
newClassName - The name of the new dippable class.
beanInfo -
true means a BeanInfo was created for the new dippable class; false otherwise.
 o createDipSerFiles
 protected void createDipSerFiles()
Creates .ser files for every pre-Dip added to the dippable bean.

 o morph
 protected void morph(String beanToMorph,
                      String interfaceName,
                      boolean useInherit,
                      String newName,
                      boolean beanInfo,
                      String relativeNewClassName) throws NullPointerException
Morph the class.
  1. Create temporary directory
  2. Generate morphed source code
  3. Compile

Parameters:
beanToMorph - The package qualified name of the class to morph.
interfaceName - The interface the new dippable bean should implement.
useInherit -
true means create the new dippable bean through inheritance; false means create the new dippable bean through aggregation.
newName -
A String containing a name for the new dippable bean. If null, the name of the dippable bean is based on the className argument.

This parameter can be null.

beanInfo -
true means create a BeanInfo for the new dippable class; false means do not create a BeanInfo.
relativeNewClassName - The package-qualified class name of the new morphed class.
Throws: NullPointerException
Thrown if using aggregation but the interfacename is blank.
 o compile
 protected boolean compile(String fileName,
                           String tmpDir)
Compiles the file.

Parameters:
fileName - The name of the file to compile.
tmpDir - The directory where the file resides.
 o finalize
 protected void finalize() throws Throwable
Disposes of system resources and performs other cleanup before garbage collection.

Throws: Throwable
Not thrown directly by this logic.
Overrides:
finalize in class Object
 o getInterfaces
 protected void getInterfaces(Class c,
                              Vector nameVector)
Gets the names of all the interfaces implemented by a class and puts them in a vector.

Parameters:
c - The class to check.
nameVector - The vector to contain the interface names.

All Packages  Class Hierarchy  This Package  Previous  Next  Index