The
JavaObject stereotype
includes the
following part-level properties:
- packageName
- A
string (enclosed in quotation marks) containing the package
name for the external Java™ object.
- javaName
- A string (enclosed in quotation
marks) containing the class name
for the Java object, if its name collides
with a reserved EGL word.
Variable declarations
can carry the following properties:
- @javaProperty
- This complex property tells EGL to use Java get
and set methods to obtain values for variables in the Java object. You can use it without specifying
method names if the methods include the name of the variable as shown.
That is, if the variable is AdjustedGrossIncome and
the Java object contains methods named getAdjustedGrossIncome() and setAdjustedGrossIncome(),
then you only need to add the complex property, as in this example:
AdjustedGrossIncome FLOAT { @JavaProperty };
- Note that Java names are case sensitive, so
if your variable is named adjustedGrossIncome and
the get and set methods have the same names as above, specify the
names using the following properties:
- getMethod
- A
string (enclosed in quotation marks) containing the name of
the get method for the specified variable (do not include parentheses).
The method has no parameters, and its return value has the same type
as the field.
- setMethod
- A string
(enclosed in quotation marks) containing the name of
the set method for the specified variable (do not include parentheses).
The method has one parameter that has the same type as the field.
By convention the setMethod returns void (does not have a return
value), but no error condition results if the method returns a value.
- If you specify only one of these methods,
EGL assumes the other
is not available. Any expression that causes invocation of the missing
method cannot pass EGL validation:
adjustedGrossIncome FLOAT {
@JavaProperty {
getMethod="getAdjustedGrossIncome" } };
...
// cannot set adjustedGrossIncome
adjustedGrossIncome = grossIncome - deductions; // validation error!
- The Java method identified by the getMethod
property has no parameters, and its return value has the same type
as the field. The Java method identified by the setMethod
property has one parameter whose type is the same type as the field.
By convention the setMethod returns void (has no return value), but
no error condition results if the method returns a value.
- @eventListener
- The event listener is a common
pattern in Java.
The @eventListener complex property gives
EGL the information it needs to generate Java code
that conforms to the event listener pattern. This means setting up
a Delegate part as an event listener; see Delegate part. A typical listener might
call a specified function when the user clicks a button. The property
attaches to an array of delegate function variables; you can set up
many listeners for a given event, all of which are called when the
event occurs. The delegate type itself defines the necessary signature
that is appropriate for functions that are to be invoked as event
handlers.
- This complex property contains the following property
fields:
- addMethod
- A string (enclosed in quotation
marks) containing the name of
the method that adds a listener to the Java object
(do not include parentheses).
- listenerType
- A string (enclosed in quotation marks) containing the Java class name (including package name) that
handles the actual events.
- method
- A
string (enclosed in quotation marks) containing the name of
the method to be invoked within the listenerType class.
- javaName
- A string
(enclosed in quotation marks) containing the name of
a variable or function whose name must be aliased in EGL. The usual
reason for such an alias is that the Java name
is an EGL reserved word, as in the following example:
Function nextElement() { JavaName = "next" };