/**
* Return the result map.
*/
public ProcessData resultData () {
ProcessData res = new DefaultProcessData ();
for (Node child = instance.getFirstChild(); child != null;
child = child.getNextSibling()) {
if (!(child instanceof Element)
|| !((Element)child).getNodeName().equals("ActualParameter")) {
continue;
}
Element param = (Element)child;
String name = param.getAttribute("name");
FormalParameter fp = null;
for (int i = 0; i < formalParameters.length; i++) {
if (formalParameters[i].id().equals(name)) {
fp = formalParameters[i];
break;
}
}
if (fp == null || fp.mode().equals(FormalParameter.Mode.IN)) {
continue;
}
if (XPDLUtil.isXMLType(fp.type())) {
SAXEventBufferImpl saxVal = new SAXEventBufferImpl();
try {
Transformer t
= SAXTransformerFactory.newInstance().newTransformer();
t.transform(new DOMSource(param),
new SAXResult(new ChildrenOnlyFiler(saxVal)));
} catch (TransformerConfigurationException e) {
logger.error(e.getMessage(), e);
} catch (TransformerFactoryConfigurationError e) {
logger.error(e.getMessage(), e);
} catch (TransformerException e) {
logger.error(e.getMessage(), e);
}
res.put(fp.id(), saxVal);
} else {
StringBuffer content = new StringBuffer();
for (Node pChild = param.getFirstChild(); pChild != null;
pChild = pChild.getNextSibling()) {
if (pChild.getNodeType() == Node.TEXT_NODE
|| pChild.getNodeType() == Node.CDATA_SECTION_NODE) {
content.append(pChild.getNodeValue());
}
}
if (fp.type().equals(String.class)) {
res.put(fp.id(), content.toString());
} else if (fp.type().equals(Boolean.class)) {
res.put(fp.id(), (new Boolean(content.toString())));
} else if (fp.type().equals(Long.class)) {
res.put(fp.id(), Long.valueOf(content.toString()));
} else if (fp.type().equals(Double.class)) {
res.put(fp.id(), Double.valueOf(content.toString()));
} else if (fp.type().equals(Date.class)) {
// Convert date to datetime
if (content.indexOf("T") < 0) {
content.append("T00:00:00");
}
try {
res.put (fp.id(),
XMLUtil.parseXsdDateTime(content.toString()));
} catch (ParseException e) {
logger.error ("Cannot parse XSD datetime: "
+ content.toString());
}