struct.setPredicate(getValueOfFirstElement("Predicate", elem));
}
/** Parses a field profile */
private Field parseFieldProfile(Element elem) throws ProfileException {
Field field = new Field();
log.debug(" Parsing field profile: " + elem.getAttribute("Name"));
field.setUsage(elem.getAttribute("Usage"));
String itemNo = elem.getAttribute("ItemNo");
String min = elem.getAttribute("Min");
String max = elem.getAttribute("Max");
try {
if (itemNo.length() > 0) {
field.setItemNo(Short.parseShort(itemNo));
}
} catch (NumberFormatException e) {
throw new ProfileException("Invalid ItemNo: " + itemNo + "( for name " + elem.getAttribute("Name") + ")", e);
} // try-catch
try {
field.setMin(Short.parseShort(min));
if (max.indexOf('*') >= 0) {
field.setMax((short) -1);
} else {
field.setMax(Short.parseShort(max));
}
} catch (NumberFormatException e) {
throw new ProfileException("Min and max must be short integers: " + min + ", " + max, e);
}
parseAbstractComponentData(field, elem);
int childIndex = 1;
NodeList children = elem.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node n = children.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element child = (Element) n;
if (child.getNodeName().equalsIgnoreCase("Component")) {
Component comp = (Component) parseComponentProfile(child, false);
field.setComponent(childIndex++, comp);
}
}
}
return field;