The cleanse() method sends “dirty” data to a Director cleansing server and receives the “clean” (or enriched) data. Data is cleansed according to the business rules available to the target cleansing server during server startup.
Before you invoke the cleanse() method, you must use the attach() method to obtain a handle to the cleansing server.
Syntax
public void cleanse(int handle,
java.lang.String trillName[],
java.lang.String inputData[],
java.lang.String updtRule[],
java.lang.String outputData[],
int retCode[]);
Parameters
Name |
Type |
Use |
Length |
Description |
---|---|---|---|---|
handle |
int |
In |
–– |
Handle for a Director cleansing server instance. |
trillName |
string[ ] |
In |
n* |
Array of strings that contains the field names of the data to be cleansed. These field names correspond to the field names in DDL files. |
inputData |
string[ ] |
In |
n* |
Array of strings containing data to be cleansed. |
updtRule |
string[ ] |
In |
n* |
Array of strings that contains update rules for the returned data. |
outputData |
string[ ] |
Out |
n* |
Array of strings that contains the cleansed data on return. Must be pre-allocated by the caller with the correct number of elements. |
retCode |
int[ ] |
Out |
4 |
Error code that indicates method call status. |
n* indicates the length is platform-specific; that is, it depends on the platform on which the program runs.
Return Values
Refer to Return Values.
Example
import java.util.*;
import java.io.*;
import java.lang.*;
import trillium.director.*;
class CleanseMulti {
public static void main(String[] args) {
TrilTGenClient testClient = new TrilTGenClient();
// Return code and handle
int[] retCode= new int[1];
int handle = 0;
// Miscellaneous processing
int i;
int j;
int maxOut;
// System and Server ID for attach()
char systemID = 'G';
String serverName = "Cleanser";
// Data for Cleanser
String[] trillName = {"LINE_01",
"LINE_03",
"LINE_09",
"FirstName",
"HouseNo",
"StreetAddress",
"City",
"State",
"PostalCode",
"Country"};
String[] updtRule = {"",
"",
"",
"PR_GIVEN_NAME1_RECODED_01",
"dr_house_number1",
"dr_street_name",
"dr_city_name",
"dr_region_name",
"dr_postal_code",
"WINDOW_KEY_01",
"WINDOW_KEY_03"};
String[] inputData = {"john smith",
"164 lexington",
"01821"};
// Create array that will contain the returned cleansed data
// Must be initalized large enough to contain all returned elements
String[] outputData = new String[12];
// Attach to a cleansing server once
handle = testClient.attach(systemID, serverName, retCode);
if (retCode[0] == 0) { // If we got a cleansing server
// Loop 10 times to cleanse the same record
for (i = 0; i < 10; i++) {
testClient.cleanse(handle, trillName, inputData, updtRule,
outputData, retCode);
if (retCode[0] != 0) {
System.out.println("cleanse method returned" +
retCode[0]);
}
maxOut = outputData.length;// Print the cleansed data
if (maxOut > 0) {
for (j = 0; j < maxOut; j++) {
System.out.println(outputData[j]);
}
}
}
// When done, release cleansing server
testClient.release(handle, retCode);
}
}