Pentaho Data Integration
InstallationBusiness AnalyticsCToolsData CatalogData QualityLLMs
  • Overview
    • Pentaho Data Integration ..
  • Data Integration
    • Getting Started
      • Configuring PDI UI
      • KETTLE Variables
    • Concepts & Terminolgy
      • Hello World
      • Logging
      • Error Handling
    • Data Sources
      • Flat Files
        • Text
          • Text File Input
          • Text File Output
        • Excel
          • Excel Writer
        • XML
          • Read XML
        • JSON
          • Read JSON
      • Databases
        • CRUID
          • Database Connections
          • Create DB
          • Read DB
          • Update DB
          • Insert / Update DB
          • Delete DB
        • SCDs
          • SCDs
      • Object Stores
        • MinIO
      • SMB
      • Big Data
        • Hadoop
          • Apache Hadoop
    • Enrich Data
      • Merge
        • Merge Streams
        • Merge Rows (diff)
      • Joins
        • Cross Join
        • Merge Join
        • Database Join
        • XML Join
      • Lookups
        • Database Lookups
      • Scripting
        • Formula
        • Modified JavaScript Value
        • User Defined Java Class
    • Enterprise Solution
      • Jobs
        • Job - Hello World
        • Backward Chaining
        • Parallel
      • Parameters & Variables
        • Parameters
        • Variables
      • Scalability
        • Run Configurations
        • Partition
      • Monitoring & Scheduling
        • Monitoring & Scheduling
      • Logging
        • Logging
      • Dockmaker
        • BA & DI Servers
      • Metadata Injection
        • MDI
    • Plugins
      • Hierarchical Data Type
  • Use Cases
    • Streaming Data
      • MQTT
        • Mosquitto
        • HiveMQ
      • AMQP
        • RabbitMQ
      • Kafka
        • Kafka
    • Machine Learning
      • Prerequiste Tasks
      • AutoML
      • Credit Card
    • RESTful API
    • Jenkins
    • GenAI
  • SETUP
    • Windows 11 Pentaho Lab
  • FAQs
    • FAQs
Powered by GitBook
On this page
  1. Data Integration
  2. Enrich Data
  3. Scripting

User Defined Java Class

PreviousModified JavaScript ValueNextEnterprise Solution

Last updated 1 year ago

Demonstration to illustrate the Modified JavaScript Value step. here we're going to usethe replace function to replace characters in a string.

In this guided demonstration, you will:

  • Configure the following steps:

    • User Defined Java Class

This Java code is part of a class or method that processes rows of data.

Let's break it down:

  1. Import Statements:

    import java.util.*;

    These statements import the java.util package, which includes various utility classes like Calendar.

  2. Private Fields:

    private int yearIndex;
    private Calendar calendar;

    These are private instance fields of the class. yearIndex is an integer, and calendar is an instance of the Calendar class.

  3. processRow Method: This method is used to process rows of data. It takes two parameters, StepMetaInterface smi and StepDataInterface sdi, and it may throw a KettleException.

    • It checks if there is a row available for processing using getRow(). If there is no row, it marks the output as done and returns false.

    • The if (first) block initializes some variables the first time this method is called. It finds the index of a field named "YEAR" in the input data, creates a Calendar instance, and clears it.

    • It resizes the outputRowData array to match the output row's metadata size.

    • It extracts the year value from the input row using getInteger and calculates the Easter date using the easterDate method.

    • It adds the Easter date to the output row data and puts it into the output stream using putRow.

  4. easterDate Method: This method calculates the date of Easter for a given year using the algorithm to determine the date of Easter Sunday.

    • It takes the year as a parameter.

    • It performs several mathematical calculations to determine the day, month, and year of Easter based on the input year.

    • Finally, it sets the calculated date in the calendar instance and returns the Date object representing the Easter date.

Overall, this code is part of a data processing routine, and the easterDate method calculates the date of Easter for a given year using a well-known algorithm for determining Easter's date.

User Defined Java Class
User Defined Java Class - Calender