on 04-25-2016 6:37 PM
I am in need of some help. We are writing a UDF to gather data from multiple sources. Several of those sources are already built UDF functions in another library. We can call the UDF functions from the other library, but we are having issues with parsing the data that is returned.
As an example:
UDF A->genAddressText(String[] inXML, String[] inQualifier, ResultList result);
This function will parse the XML and return formatted address lines for the XML given.
UDF B->genInstructions(String[] inXML, ResultList result);
This is the new function that will call the UDF A->genAddress();
In the genInstructions - we call the UDF A->genAddress as such:
String[] inQualifier = {"ZC"};
String[] inDestEurope = { "true" };
//Calling genAddressText UDF to get Final Destination Address
ResultListImpl address = new ResultListImpl();
_Forms_test_.genAddressText(inxml,inQualifier, inDestEurope, (ResultList) address,container);
container.getTrace().addWarning ("address is empty? " + (address.isEmpty()? " true": " false"));
String[] finalDestination = null;
if (address != null) {
container.getTrace().addWarning ("address is not null");
finalDestination = (String[]) address.get();
}
address.clear();
However, we get a null pointer exception when there is any data. It seems the "get" is not returning a String[] or Object[] but just an Object. Is there a way to parse the records in the ResultList returned?
I have reviewed and tried the example shown in this thread, but it doesn't work either:
Hi Brian
In order to parse the content in the ResultList, you need to iterate through it using the get() method one at a time, and then use pop() to move to the next value. ResultList can accept different content, so not necessarily everything is stored as String.
Refer below an example of one UDF calling another and the result.
First UDF which stores two values, one String and one integer.
Second UDF calls first UDF, then iterate through the ResultList
Output when second UDF is used in mapping.
Hope this helps.
Regards
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.