-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod.java
More file actions
135 lines (107 loc) · 4.47 KB
/
Method.java
File metadata and controls
135 lines (107 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package javaxt.webservices;
import org.w3c.dom.*;
import javaxt.xml.DOM;
//******************************************************************************
//** Method Class
//******************************************************************************
/**
* Used to represent a web method.
*
******************************************************************************/
public class Method {
private String Name;
private String Description;
//private String URL;
//private String NameSpace;
private String SoapAction;
private String ResultsNode;
private NodeList Parameters = null;
private NodeList Outputs = null;
//**************************************************************************
//** Constructor
//**************************************************************************
/** Used to retrieve a method from an SSD Method Node */
protected Method(Node MethodNode){
NamedNodeMap attr = MethodNode.getAttributes();
Name = DOM.getAttributeValue(attr, "name");
SoapAction = DOM.getAttributeValue(attr, "soapAction");
ResultsNode = DOM.getAttributeValue(attr, "resultsNode");
//Method.URL = Service.URL;
//Method.NameSpace = Service.NameSpace;
NodeList ChildNodes = MethodNode.getChildNodes();
for (int j=0; j<ChildNodes.getLength(); j++ ) {
if (ChildNodes.item(j).getNodeType()==1){
String NodeName = ChildNodes.item(j).getNodeName();
String NodeValue = ChildNodes.item(j).getTextContent();
if (NodeName.toLowerCase().equals("description")){
Description = NodeValue;
}
if (NodeName.toLowerCase().equals("parameters")){
Parameters = ChildNodes.item(j).getChildNodes();
}
if (NodeName.toLowerCase().equals("outputs")){
Outputs = ChildNodes.item(j).getChildNodes();
}
}
}
}
public String getName(){return Name;}
public String getDescription(){return Description;}
public String getSoapAction(){return SoapAction;}
public String getResultsNodeName(){return ResultsNode;}
//**************************************************************************
//** getParameters
//**************************************************************************
/** Returns a list of input parameters associated with this method.
*/
public Parameters getParameters(){
//Note that we don't store parameters as a class variable. Instead, we
//extract parameters from the SSD. This is important. Otherwise, the
//param values get cached
Parameter[] parameters = getParameters(Parameters, "parameter");
if (parameters==null) return null;
else return new Parameters(parameters);
}
//**************************************************************************
//** getOutputs
//**************************************************************************
/** Returns a list of outputs returned by this method. There should be only
* one result. Use the getResultsNodeName() method to find the correct
* output.
*/
public Outputs getOutputs(){
Parameter[] parameters = getParameters(Outputs, "output");
if (parameters==null) return null;
return new Outputs(parameters, ResultsNode);
}
//**************************************************************************
//** getParameters
//**************************************************************************
/** Used to retrieve an array of parameters from an SSD NodeList
*/
private Parameter[] getParameters(NodeList parameterNodes, String tagName){
java.util.ArrayList<Parameter> parameters = new java.util.ArrayList<>();
for (Node parameterNode : DOM.getNodes(parameterNodes)){
if (parameterNode.getNodeName().equalsIgnoreCase(tagName)){
try{
parameters.add(new Parameter(parameterNode));
}
catch(InstantiationException e){
e.printStackTrace();
}
}
}
if (parameters.isEmpty()){
return null;
}
else{
return parameters.toArray(new Parameter[parameters.size()]);
}
}
public boolean equals(String MethodName){
return Name.equalsIgnoreCase(MethodName);
}
public String toString(){
return Name;
}
}