I have a problem now for WM 4.0.
I need to handle a bunch of attributes, with different values inside, could be number or text. For number I need to format it and for text I just leave it as it is.
Currently I do it by search “.” in the values, but the problem is some of the values could be “aaaaaaa 5.0” or “bbb111.b”, this will cause exception in numberformat function.
So I am lost, is there any functions which can distinguish number and text?
You can use PSUtilities.string:isNumeric service to determine if your input is text or number.
I am afraid in 4.0 there is no this function…
You can write your own java/wM service, its pretty simple.
Do a math operation with the input, if an exception occurs input is string else its numeric.
Write Java Code as below
IDataCursor pipelineCursor = pipeline.getCursor();
pipelineCursor.first( “input” );
String input = (String)pipelineCursor.getValue();
String isNumeric = “true”;
float fNumber = Double.valueOf(input).floatValue();
catch (Exception e)
isNumeric = “false”;
For the above code we are getting a strange output for any number which ends with ’ f ’ , its saying True .Does this takes as numeric/float in webmethods code ?
Eg: if we give input as 456f the output we are getting is True which should not be!
Please can anyone help me in this ?
Yes, the f is considered a part of the floating point literal by Java. (Java is not “webMethods code.”) You’ll find that F, f, D, and d are also interpreted as part of the number. http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798
If you need to evaluate a string to detect non-numeric characters more restrictively, you can use a variety of techniques. A search of the web for “java isnumeric” will turn up some interesting information you may be able to leverage.