Reversing

 

Introduction

The reverse feature allows existing library classes to be used during the modeling phase.  The purpose of this is to allow the generalization of these classes, their implementation or their use in modeling.

 

To reverse a class, you must have its .class file, either as such or compressed in a .zip or .jar file.  If you also have the .java source code, a complete reverse of the code and javadoc comments can be carried out.  If this is not the case, only an interface reverse will be concerned.

 

We are now going to reverse the "Applet" class and the "Button" class.  If you do not have the source file for these classes, make sure that the "ReverseJavaCode" and "ReverseJavaDoc" parameters have not been checked.

 

 

Warning

A class created through a reverse will receive an identifier in the same way as an object created in an explorer or in a graphic editor.

 

If two people reverse the same class in two different projects, Objecteering will consider them as two different objects.

 

To avoid losing links to the reversed classes during the reverse, run the reverse operation in the reference project from which all the classes used are imported.

 

 

Running the command

The command for running the reverse can be found in any package's context menu (as shown in Figure 28).

 

Figure 28. Running the reverse command

 

Steps:

1.      In the explorer, right-click on the "FirstSteps" package to open the associated context menu.

2.      Run the "Java Developer/Reverse Java binaries" command.

 

 

Selecting the directory containing the elements to be reversed

In the first Java reverse wizard window, the path to the application to be reversed into the project should be entered (as shown in Figure 29).

 

Figure 29. Selecting the path of the classes to be reversed

 

 

Selecting the classes to be reversed

The second Java reverse wizard windowis used to select the elements to reverse into the project (Figure 30).

 

Figure 30. Selecting the files to be reversed

 

Select the elements you wish to reverse by checking the associated tickbox.

 

The "Choose a reverse mode" field is used to select the desired reversal level.

 

There are three available reversal levels:

·         Simple structural

·         Complete structural

·         Complete reverse (this reverse level is only available when reversing from sources)

 

For further details, please see "Three reverse levels".

 

Click on the "Next" button to proceed to the next step.

 

 

Selection of the application libraries

The final window of the Wizard is used to specify the classpath of the application to be reversed (Figure 31).

 

Figure 31. Adding the libraries of the application

 

Use the "Add" and "Remove" buttons to add or remove libraries (jar files or directories).

 

To go back to the previous step, click on the "Previous" button.

 

To launch the reverse operation, click on the "Reverse" button.

 

 

Result

A package named "java" appears in the "FirstSteps" package (see Figure 32).  It contains the "applet" package that contains the "Applet" class and the "awt" package containing the "Button" class.

 

It is now possible to create a class that generalizes "Applet" and that contains "Button" type attributes.

 

Other classes have also appeared.  "Applet" and "Button" need these classes either as attributes, or as method parameters.

 

Figure 32. Result of the reverse as seen in the explorer