cancel
Showing results for 
Search instead for 
Did you mean: 

Required UDF for comparing values within same context

Former Member
0 Kudos

I have to compare values within the same context.I am getting boolean values for that field.If all the values in the same context are true,then the result should be true .Otherwise false should be passed.

If input is-

<context>

true

false

true

<context>

true

true

<context>

Output should be as-

<context>

false

<context>

true

<context>

Please suggest how to acheive this?..its urgent

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nagarjuna,

You can do it without going for UDF's.

Boolean function if without else can be used here. Pass values 'true' and 'false' to that function.

and use constant 'true' as a second argument of that function.

This will return 'true; for input value 'true'. else it will suppress the output.

Then just remove that suppression and you will get what you want.

Regards,

Shri

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

use a udf of type context with parameter inputValue:

String returnValue = "true";

for (int index = 0; index < inputValue.length; index++) {

if (inputValue\[index\] == "false") {

returnValue = "false";

}

}

result.addValue(returnValue);

Regards

Patrick

Former Member
0 Kudos

Hi,

Check with this UDF

Src>UDF>target


public void context1(String[] a,ResultList result,Container container)
{
    int k = 0;
    int arrayLength = a.length;
    if (arrayLength > 0)
      {
        String firstElement = a[0];
        for (int i = 1; i < arrayLength; ++i)
              {
               if(!(a<i>.equalsIgnoreCase(firstElement)))
                {
                 k = 0;
                 break;
                }
               else
                 k = 1;
             }
       }
if(k == 1)
    result.addValue("true");
else
    result.addValue("false");

}

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

1.Create a Context UDF.

2.Pass the source fields and use the following mapping.

Source field ---> UDF -


> collapseContext(node function) -


> Target filed

Use this code in the UDF

int flag=0;
 for(int i=0;i<a.length;i++)
{
if (a<i>.equalsIgnoreCase("false") )
{
result.addValue("False");
flag = 1;
}
}
if (flag ==0) result.addValue("True");

Thanks

SaNv...

Former Member
0 Kudos

set Context in UDF....

check value of false.. if it so put False.. else true