Getting Java node properties - 3 - 3.12

Data360 Analyze Server Help

Product type
Software
Portfolio
Verify
Product family
Data360
Product
Data360 Analyze
Version
3.12
Language
English
Product name
Data360 Analyze
Title
Data360 Analyze Server Help
Copyright
2023
First publish date
2016

Java nodes can be made to be generic and reusable by defining node properties, and accessing them from within the node code.

There are two mechanisms for accessing properties within a Java node:

Note: The recommended approach is to use the Run Time Property Names to obtain node properties.

Using run time property names

For example, in the JavaCode property, you define the following method propertyBase:

public String propertyBase() {

return "ls.brain.node.sumExample";

}

This means that all properties will have the following run time property name format, where <runtime-property-name-extension> is the suffix of the run time property name:

propertyBase().<runtime-property-name-extension>

For example, for the OutputFieldName property the propertyBase part of the run time property name is ls.brain.node.sumExample and the suffix is outputFieldName:

ls.brain.node.sumExample.outputFieldName

Tip: You can view advanced property details, including the Run Time Property Name by clicking the menu button to the right of a property on the Define tab of the Properties panel, then selecting Edit Details. The Edit Property Definition dialog opens, showing the Run Time Property Name at the bottom.

Variables are defined within the JavaCode class to store these properties, as follows:

JavaCode property

Then, within the setup method of the node these properties are loaded into the variables, as follows:

JavaCode property

Consider the first property from the above code example. This code obtains the Properties object via the properties() accessor defined on the Node interface (see the "laeJavaApi" in the following location: <Data360Analyze installation directory>/docs/lae). The code then attempts to access the boolean property called:

propertyBase() + ".outputFloat"

From the propertyBase() method, this corresponds to the Run Time Property Name:

ls.brain.node.sumExample.outputFloat

This Run Time Property Name is used by the OutputAsFloat property.

With all of this put together, the following line states "obtain the Boolean property OutputAsFloat and store it in the variable m_outputAsFloat":

m_outputAsFloat = properties().getBoolean( propertyBase() + ".outputFloat");

Textual substitution of properties

You can use textual substitution to access properties within the Java code, using the {{^propertyname^}} syntax, see Explicit property reference.

Tip: Where possible, the Run Time Property Name approach is preferable as it allows greater control of errors that can occur during property evaluation. Also, using the Run Time Property Name allows you to optimize the compilation of the Java node. Within the JavaCode property, textual substitution should be used in places where it is not possible to use the Run Time Property Name to obtain the property value. Wherever the value needs to be directly substituted into the Java code, then textual substitution should be used.

The following example shows textual substitution of the name of the class and the name of the package within which it lies. In general, the Java code needs to be declared within a package with the same name as the value of the JavaPackage property. Similarly, the code needs to be defined within a class with the same name as the value of the JavaClass property:

package {{^JavaPackage^}};…public class {{^JavaClass^}} extends SimplifiedNode

In these cases, it would not be possible to read in the value of the JavaPackage or JavaClass property into a variable to then be used as the package or class name, therefore the textual substitution approach is used.