on 05-27-2008 2:21 PM
Hi guys,
i have a UDF, which used for counting of textlines in an order depending on the language.
there global class Counter with a int and for each language a Counter instance will be created.
therefore the UDF gets 3 input parameters.
If the messages has only 1 order_line the mapping is fine, otherwise the counting is corrupt.
No line count value is created.
I determined following ...
1. If the 3 parameters of the UDF are Constants, the mapping fails.
2. If it gets a list of values in
param queue
e.g. the line number the mapping works.
I tried to get the error using the MappingTrace, but it seems that in the first situation the mapping is not conducted, because there is at least no trace message.
the mapping have to work for constants as well as a list of values (param queue)
is there a special behaviour of constants?
here is the code of the UDF
/**
* This method is used to count the textlines according to one language.
*
* @param a
* If <code>a</code> is true the line have to be recognized by
* the counter, otherwise the line will be ignored.
* @param queue
* queue of textlines which determines how many lines have to be
* created
* @param language
* specifies the language, if there isn`t a counter for this
* language yet, a new counter will be created
* @param result
* @param container
*/
MappingTrace trace;
trace = container.getTrace();
Counter c = (Counter) mCounters.get(language[0]);
if (c == null) {
c = new Counter();
mCounters.put(language[0], c);
}
trace.addInfo("length 1st " + a.length);
trace.addInfo("length 2st " + queue.length);
trace.addInfo("length 3st " + language.length);
if (a.length != 0 && queue.length != 0 && language.length != 0) {
if (a[0].equals("true")) {
for (int i = 0; i < queue.length; i++) {
result.addValue(Integer.toString(c.getNextValue()));
trace.addInfo("value of Counter " + language[0] + " " + c.counter);
}
}
}
I hope the issue is understandable.
thanks for your help.
kind regards
Jochen
It would be helpful if you post the source XML, the targetXMl, as you request it and the whole source code of the UDF.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ll;
thanks for your replies.
I solved the error.
It was caused by using the "context" option when defining the UDF. Obviously the behaviour of Constant Paramters is not defined for option "context", so that only the first time the mapping is done.
I replaced the constant by a list of values that determines the count the mapping should be conducted.
Thanks for helping
Regards
Jochen
Hi,
You have written a.length here length is variable that is applicable for intergers, long, ect., of premitive datatypes in java. If you want to deal with string you have to use a.length() method in String Class. I think this might be the reason you will get results for constant values.
Reward points if needful.
Thanks,
RamuV
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 | |
25 | |
12 | |
9 | |
6 | |
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.