* @param isReferenced
*/
private boolean parseParamNode(Node paramElement, Object parentNode, boolean isReferenced) {
if (containsOnlyAllowedChildren(paramElement, WadlXml.paramChildren)) {
if (containsOnlyAllowedAttributes(paramElement, WadlXml.paramAttributes)) {
Node hrefNode = paramElement.getAttributes().getNamedItem(WadlXml.param_href);
if (hrefNode != null) {
getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);
}
else {
String name = "";
String style = "";
String type = "";
String defaultValue = "";
String path = "";
boolean isRequired = false;
boolean isRepeating = false;
String fixed = "";
Node nameNode = paramElement.getAttributes().getNamedItem(WadlXml.param_name);
if (nameNode != null) {
name = nameNode.getNodeValue();
}
Node styleNode = paramElement.getAttributes().getNamedItem(WadlXml.param_style);
if (styleNode != null) {
style = styleNode.getNodeValue();
}
Node pathNode = paramElement.getAttributes().getNamedItem(WadlXml.param_path);
if (pathNode != null) {
path = pathNode.getNodeValue();
}
Node typeNode = paramElement.getAttributes().getNamedItem(WadlXml.param_type);
if (typeNode != null) {
type = typeNode.getNodeValue();
}
// if no type is given use string as the default value
if (type.equals("")) {
type = TypeEstimator.typeString;
}
Node defaultValueNode = paramElement.getAttributes().getNamedItem(WadlXml.param_default);
if (defaultValueNode != null) {
defaultValue = defaultValueNode.getNodeValue();
}
Node fixedNode = paramElement.getAttributes().getNamedItem(WadlXml.param_fixed);
if (fixedNode != null) {
fixed = fixedNode.getNodeValue();
}
Node isRequiredNode = paramElement.getAttributes().getNamedItem(WadlXml.param_required);
if (isRequiredNode != null) {
if (isRequiredNode.getNodeValue().equals("true")) {
isRequired = true;
}
}
Node isRepeatingNode = paramElement.getAttributes().getNamedItem(WadlXml.param_repeating);
if (isRepeatingNode != null) {
if (isRepeatingNode.getNodeValue().equals("true")) {
isRepeating = true;
}
}
ParamNode param = null;
if (!isReferenced) {
if (parentNode instanceof ResourceNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ResourceNode) parentNode, ((ResourceNode) parentNode).getApplication());
((ResourceNode) parentNode).addParam(param);
}
else if (parentNode instanceof RequestNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
((RequestNode) parentNode).addParam(param);
}
else if (parentNode instanceof ResponseNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
((ResponseNode) parentNode).addParam(param);
}
else if (parentNode instanceof RepresentationNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (RepresentationNode) parentNode, ((RepresentationNode) parentNode).getApplication());
((RepresentationNode) parentNode).addParam(param);
}
else if (parentNode instanceof FaultNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (FaultNode) parentNode, ((FaultNode) parentNode).getApplication());
((FaultNode) parentNode).addParam(param);
}
else if (parentNode instanceof ApplicationNode) {
param = new ParamNode(name, type, TypeEstimator.manual, style, isRequired, isRepeating, defaultValue, fixed, path, "", (ApplicationNode) parentNode, ((ApplicationNode) parentNode));
((ApplicationNode) parentNode).addParam(param);
}
Node idNode = paramElement.getAttributes().getNamedItem(WadlXml.param_id);
if (idNode != null) {
param.setId(idNode.getNodeValue());
}
// paramChildren = {optionNode, linkNode, docNode}
NodeList childNodes = paramElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
if (childNodes.item(i).getNodeName().equals(WadlXml.optionNode)) {
if (!parseOptionNode(childNodes.item(i), param));
}
else if (childNodes.item(i).getNodeName().equals(WadlXml.linkNode)) {
if (!parseLinkNode(childNodes.item(i), param));
}
else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {
if (!parseDocNode(childNodes.item(i), param));
}
}
}
else {
Node idNode = paramElement.getAttributes().getNamedItem(WadlXml.param_id);
if (parentNode instanceof ResourceNode) {
param = new ParamNode(idNode.getNodeValue(), true, (ResourceNode) parentNode, ((ResourceNode) parentNode).getApplication());
((ResourceNode) parentNode).addParam(param);
}
else if (parentNode instanceof RequestNode) {
param = new ParamNode(idNode.getNodeValue(), true, (RequestNode) parentNode, ((RequestNode) parentNode).getApplication());
((RequestNode) parentNode).addParam(param);
}
else if (parentNode instanceof ResponseNode) {
param = new ParamNode(idNode.getNodeValue(), true, (ResponseNode) parentNode, ((ResponseNode) parentNode).getApplication());
((ResponseNode) parentNode).addParam(param);
}
else if (parentNode instanceof RepresentationNode) {
param = new ParamNode(idNode.getNodeValue(), true, (RepresentationNode) parentNode, ((RepresentationNode) parentNode).getApplication());
((RepresentationNode) parentNode).addParam(param);
}
else if (parentNode instanceof FaultNode) {
param = new ParamNode(idNode.getNodeValue(), true, (FaultNode) parentNode, ((FaultNode) parentNode).getApplication());
((FaultNode) parentNode).addParam(param);
}
else if (parentNode instanceof ApplicationNode) {
param = new ParamNode(idNode.getNodeValue(), true, (ApplicationNode) parentNode, (ApplicationNode) parentNode);
((ApplicationNode) parentNode).addParam(param);
}
}
}
}