Table of Contents

Search

  1. Preface
  2. Working with Transformations
  3. Aggregator Transformation
  4. Custom Transformation
  5. Custom Transformation Functions
  6. Data Masking Transformation
  7. Data Masking Examples
  8. Expression Transformation
  9. External Procedure Transformation
  10. Filter Transformation
  11. HTTP Transformation
  12. Identity Resolution Transformation
  13. Java Transformation
  14. Java Transformation API Reference
  15. Java Expressions
  16. Java Transformation Example
  17. Joiner Transformation
  18. Lookup Transformation
  19. Lookup Caches
  20. Dynamic Lookup Cache
  21. Normalizer Transformation
  22. Rank Transformation
  23. Router Transformation
  24. Sequence Generator Transformation
  25. Sorter Transformation
  26. Source Qualifier Transformation
  27. SQL Transformation
  28. Using the SQL Transformation in a Mapping
  29. Stored Procedure Transformation
  30. Transaction Control Transformation
  31. Union Transformation
  32. Unstructured Data Transformation
  33. Update Strategy Transformation
  34. XML Transformations

Transformation Guide

Transformation Guide

Defining Helper Code

Defining Helper Code

On the
Helper Code
tab, you can declare user-defined variables and methods for the Java transformation class in active or passive Java transformations.
After you declare variables and methods on the
Helper Code
tab, you can use the variables and methods on any code entry tab except the
Import Packages
tab.
On the
Helper Code
tab, you can declare the following types of code, variables, and methods:
  • Static code and static variables.
    Within a static block, you can declare static variables and static code. All instances of a reusable Java transformation in a mapping
    and all partitions in a session
    share static code and variables. Static code runs before any other code in a Java transformation.
    For example, the following code declares a static variable to store the error threshold for all instances of a Java transformation in a mapping:
    static int errorThreshold;
    Use this variable to store the error threshold for the transformation and access it from all instances of the Java transformation in a mapping
    and from any partition in a session
    .
    You must synchronize static variables
    in a multiple partition session or
    in a reusable Java transformation.
  • Instance variables.
    You can declare partition-level instance variables.
    Multiple instances of a reusable Java transformation in a mapping
    or multiple partitions in a session
    do not share instance variables. Declare instance variables with a prefix to avoid conflicts and initialize non-primitive instance variables.
    For example, the following code uses a boolean variable to decide whether to generate an output row:
    // boolean to decide whether to generate an output row // based on validity of input private boolean generateRow;
  • User-defined static or instance methods.
    Extends the functionality of the Java transformation. Java methods declared on the
    Helper Code
    tab can use or modify output variables or locally declared instance variables. You cannot access input variables from Java methods on the
    Helper Code
    tab.
    For example, use the following code on the tab to declare a function that adds two integers:
    private int myTXAdd (int num1,int num2) {      return num1+num2; }

0 COMMENTS

We’d like to hear from you!