Operation mapping for Java (Java code)
For each Class, Data Type or Interface scoped Operation, ACS generates a method in the code. Model and Package scoped Operations are ignored.
The generation of an Operation is derived from its child items, its properties, and the tagged values set for the Tag Definitions applied by the «Java Method» and «Java Generic» stereotypes.
Child items:
If the Operation owns
Parameters, ACS generates the parameters in the order they appear in Modeler. For Parameter mapping information, see
Parameter mapping for Java (Java code).
Example code:
public int sum(int first,
int second)
{
return first +second;
}
Properties:
• If the Abstract property is set to TRUE (Abstract check box selected on Property Pages), ACS marks the method as abstract.
Example code:
public abstract int myFunc();
• The Binding property is ignored on generation, because the compiler decides on whether it is better to have run time or compile time binding for a method.
| When the Reverser reverse engineers final class methods and final, static and private methods, the Binding property is set to At Compile. For other methods, the Reverser sets the Binding property to At Runtime. |
• If the Body property has a value, ACS may generate the value as the body of the associated method.
| Reverser Notes: When reverse engineering, the Reverser updates the Operation Body property in Modeler as follows: • If the Reverse Engineer Code Bodies check box (Reverse Engineering Options 1 page) is cleared, the Reverser does not update the Operation Body property in the Model. • If the Reverse Engineer Code Bodies check box (Reverse Engineering Options 1 page) is selected, the Reverser updates the Operation Body property with the associated method body code. | Note that blank method body code will result in the associated Operation's Body property being made blank. |
|
When updating Operation Body properties, the Reverser attempts to preserve model object references.
• If the Data Usage property is set to On Class, ACS generates the method with the static storage class.
Example code:
public class foo
{
// Operations
public static int myFunc()
{
return 0;
}
}
• The Immutable property is ignored.
• The Name property is generated as the name of the method in the code.
| ACS may modify the method name that is added to the code to make it valid for Java. You can specify the exact method name to add to the code through the CODE_GENERATION_NAME property of an Operation. Tell me more... |
• If the Return Type property is set, ACS generates the value as the method's return type.
If no data type is specified, ACS generates void by default, except for constructors in which case no return type is generated. If you want ACS to generate a different default in the absence of a data type for an Operation, change the default value that is specified in the JavaGen.ini file.
Tell me more... | Reverser Notes: When reverse engineering a method's return type: • If the return type is modeled in the Model or is going to be reverse engineered to the Model, the Operation's Return Type references the appropriate item. • If the return type is not modeled in the Model and is not going to be reverse engineered to the Model, the Operation's Data Type is set to the name of the return type as text. |
• The Timing properties (Synchronization and Duration) are ignored.
• If the Visibility property is set to Public, Protected or Private, ACS generates the method with Public, Protected or Private access, unless the Java Default Access tag definition is set to TRUE.
Example code:
public class foo
{
// Operations
public int myFunc()
{
return 0;
}
}
If Visibility property is set to Package or the Java Default Access tag definition is set to TRUE, the Access property is ignored and ACS generates the method with no access specifier.
Tag Definitions:
The following Tag Definitions are applied to an Operation by the «Java Method» stereotype:
• If the tagged value of the Java Actual Arguments tag definition has been set and the method is using a Java Generic as its data type, ACS generates the value as the arguments that are passed to the generic type.
• If the tagged value of the Java Array Spec tag definition has been set, ACS generates the value after the method data type. Note that the tagged value should be one or more pairs of empty brackets.
Example code:
public int [] MyOperation()
| When reverse engineering methods, the Reverser reverse engineers array specifications to the tagged value of the Java Array Spec tag definition. |
• If the tagged value of the Java Method Modifier tag definition has been set, ACS generates the value before the method's data type.
Example code:
public synchronized int doSomething()
{
return 0;
}
| If you set the Java Method Modifier tag definition to native, ACS does not generate any body code. |
• If the tagged value of the Java Default Access tag definition is set to TRUE, ACS generates the method with no access specifier, irrespective of how the Visibility property is set.
• If the tagged value of the Java Instance Block tag definition is set to TRUE, ACS generates the operation as an instance block.
Example code:
{
m_foo = 0;
}
• If the tagged value of the Java Needs Qualified Type tag definition is set to TRUE, ACS generates the method's data type with a qualified name.
• If the tagged value of the Java Override tag definition is set to TRUE, ACS generates the method with the @Override annotation before the method declaration.
• If the tagged value of the Java Static Block tag definition is set to TRUE, ACS generates the operation as a static block.
Example code:
static
{
// body code
}
• If the tagged value of the Java Throws tag definition has been set, ACS generates the value as part of the throws statement for the method.
Example code:
public int doSomething() throws Exception
| Reverser Notes: When reverse engineering a method's throws statement, if the Reverser can find the exception Classes in the Model, the Operation is linked to those exception Classes through the Java Throws tag definition. |
• If the tagged value of the Java Throws Text tag definition has been set, ACS generates the value as part of the throws statement for the method.
Example code:
public int doSomething() throws Exception
| Reverser Notes: When reverse engineering a method's throws statement, if the Reverser cannot find the exception Classes in the Model, the Java Throws Text tag definition records the throws statements. |
The following Tag Definitions are applied to an Operation by the «Java Generic» stereotype. If the «Java Generic» stereotype is applied to an Operation, ACS generates the Operation as a generic type.
• If the tagged value of the Java Formal Type Parameters tag definition has been set, the value is generated as the formal type parameters for the generic type.
Example code:
public static <T extends GenericClass<? super T, AClass>> void max(int a, int b){}