1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.webservice.generator.bcm;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 public class InternalMethodDescriptionParser {
38
39 private String description;
40
41 private String methodDescriptionTail;
42
43 public InternalMethodDescriptionParser(String desc) {
44 this.description = desc;
45 }
46
47
48
49
50
51
52 public List<String> parse() {
53 List<String> params = new ArrayList<String>();
54 int firstBrPos = description.indexOf('(');
55 int lastBrPos = description.indexOf(')');
56 String parameterDesc = description.substring(firstBrPos + 1, lastBrPos);
57 methodDescriptionTail = description.substring(lastBrPos +1);
58 String descToConsume = parameterDesc;
59 while (!("".equals(descToConsume))) {
60 String nextParameter = getNextParam(descToConsume);
61 params.add(nextParameter);
62
63 descToConsume = descToConsume.substring(nextParameter.length(), descToConsume.length());
64 }
65 return params;
66 }
67
68
69
70
71
72
73
74
75 private String getNextParam(String param) {
76
77 if ((param == null) || (param.equals(""))) {
78 return "";
79 }
80
81
82 if ((param.charAt(0) == 'Z') ||
83 (param.charAt(0) == 'C') ||
84 (param.charAt(0) == 'B') ||
85 (param.charAt(0) == 'S') ||
86 (param.charAt(0) == 'I') ||
87 (param.charAt(0) == 'F') ||
88 (param.charAt(0) == 'J') ||
89 (param.charAt(0) == 'D')) {
90 return new Character(param.charAt(0)).toString();
91 } else if (param.charAt(0) == '[') {
92
93 String paramArray = param.charAt(0) + getNextParam(param.substring(1, param.length()));
94 return paramArray;
95 } else if (param.charAt(0) == 'L') {
96
97 int pos = param.indexOf(';');
98 String paramArray = param.substring(0, pos + 1);
99 return paramArray;
100 } else {
101 return "";
102 }
103 }
104
105 public String getMethodDescriptionTail() {
106 return methodDescriptionTail;
107 }
108
109 public void setMethodDescriptionTail(String methodDescriptionTail) {
110 this.methodDescriptionTail = methodDescriptionTail;
111 }
112
113
114 }