POUtilImpl.jcs Sample
This topic inludes the source code for the POUtilImpl.jcs Sample.
Sample Location
This sample is located in the following directory in your WebLogic Workshop installation:
BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/localControls/nestedControls/poUtil/
Sample Source Code
01 package localControls.nestedControls.poUtil;
02
03 import java.util.StringTokenizer;
04
05 /**
06 * Provides a number formatting utility function for the
07 * VerifyFunds sample control.
08 *
09 * @jcs:jc-jar label="POUtil"
10 * @editor-info:code-gen control-interface="true"
11 */
12 public class POUtilImpl implements POUtil,com.bea.control.ControlSource
13 {
14 /**
15 * Formats a purchase order number, removing
16 * non-numeric characters.
17 *
18 * @common:operation
19 */
20 public int formatNumber(String stringNumber)
21 {
22 StringBuffer cleanString = new StringBuffer();
23
24 for (int i = 0; i < stringNumber.length(); i++)
25 {
26 if (!(stringNumber.charAt(i) < '0' || stringNumber.charAt(i) > '9'))
27 cleanString.append(stringNumber.charAt(i));
28 }
29 int number = new Integer(cleanString.toString()).intValue();
30 return number;
31 }
32 }
|