Element intf = (Element) document.createElement(SCA_SERVICE);
root.appendChild(intf);
// Go through all the signatures we have collected...
Signature s = null;
for (Iterator iter = methods.iterator(); iter.hasNext();) {
s = (Signature) iter.next();
// Each signature is an operation
Element op = document.createElement(SCA_OPERATION);
op.setAttribute(OPERATION_NAME_ATTR, s.getMethodName());
intf.appendChild(op);
Parameter[] parms = s.getParameters();
if (parms != null) {
for (int i = 0; i < parms.length; i++) {
Element parm = (Element) document
.createElement(SCA_OPERATION_PARAMETER);
String type_string = parms[i].getTypeWithoutConst()
.toString();
type_string = type_string.replaceAll(":: ", "::");
Text text = document.createTextNode(type_string);
parm.appendChild(text);
parm.setAttribute(SCA_OPERATION_PARAMETER_NAME_ATTR,
parms[i].getName());
if (parms[i].getTypeWithoutConst().intern() != parms[i]
.getType().intern()) {
parm.setAttribute(
SCA_OPERATION_PARAMETER_CONST_ATTR, "true");
}
op.appendChild(parm);
// TO DO only really stores the value
// unsafely/temporarily
// which is fine while we handle everything at the
// end of parsing the "leaf" that represents that actual
// interface/service but the below will cause the second
// service
// processed to overwite the first one in the DOM. I we
// wish
// to do some overall processing at the end we will have
// to
// use a better more XPath like key that varies by
// instance
// of the service.
intf.setAttribute(SCA_INTERFACE_NAME_ATTR, s
.getTrimClassName());
}
}
Element rc = document.createElement(SCA_OPERATION_RETURN_TYPE);
rc.appendChild(document.createTextNode(s.getReturnType()
.toString().replaceAll(":: ", "::")));
op.appendChild(rc);
root.appendChild(intf);
}
// Set the name of the Service
// here, if we are not passed one we use
// the classname from the last header function signature...
if (serviceName == null && s != null) {
serviceName = s.getTrimClassName();
}
// this is used for the proxy file name but we need to
// use the reference name if this is pulled in due to it
// being a reference!!!