0 / 0
User Defined Function, Java Integration stage

User Defined Function (DataStage)

The Java™ Integration stage supports the execution of existing user-defined functions that use JavaBeans or primitive types (that are supported by Java Stage) in their calling interface.

To execute the existing user-defined functions, the number of parameters must match the number of input links, and the return value bean must map to an output link. An exception to this rule is that when the Java Integration stage is used as a target, it does not matter whether the user-defined function returns a value or not.

The following example code shows a user-defined function that combines two input records, and writes the result to an output link:

public class UserDefinedFunction
{

   /**
    * Passes primitive type double and a bean as UDF arguments and 
* returns a bean.
    *
    * @param commission commission
    * @param input {@link InputBean} object.
    * @return output {@link UDFOutputBean} object.
    */
   public UDFOutputBean AnnualIncome(double commission, InputBean input)
   {UDFOutputBean output = new UDFOutputBean();

      output.setEmpno(input.getEmpno());
      output.setFirstName(input.getFirstName().toUpperCase());
      output.setLastName(input.getLastName().toUpperCase());

      double total = commission + 
						input.getSalary().doubleValue() + 
						input.getBonus();
      output.setIncome(total);

      return output;
   }

}
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more