if (node.getNodeName().equals("method")) {
NodeList children = node.getChildNodes();
// create Method Object
String methodName = ((Element) node).getAttribute("name");
Method method = new Method(methodName);
// loop through to fill Method Object
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
// get the Method's behavoir
if (child.getNodeName().equals("action")) {
method.setBehavoir(XMLUtils.getSimpleElementText(
(Element) child, false));
// get the Method's arguments
} else if (child.getNodeName().equals("args")) {
String name, argType = null;
NodeList grandChildren = child.getChildNodes();
// loop for every arg element
for (int k = 0; k < grandChildren.getLength(); k++) {
Node grandChild = grandChildren.item(k);
// parse arg element
if (grandChild.getNodeName().equals("arg")) {
name = ((Element) grandChild)
.getAttribute("name");
// get arg element properties
NodeList greatGrandChildren = grandChild
.getChildNodes();
for (int l = 0; l < greatGrandChildren
.getLength(); l++) {
Node greatGrandChild = greatGrandChildren
.item(l);
if (greatGrandChild.getNodeName().equals(
"type")) {
argType = XMLUtils.getSimpleElementText(
(Element) greatGrandChild,
true);
}
}
// create argument signature in Method
method
.addArgSignature(
name,
((argType.toLowerCase()
.equals("int")) ? method.INT
: method.STRING));
}
}
}
}
// store Method in list of Methods
methodRepo.put(method.getName(), method);
}
}
}