xml.append("</ContainerProperty>");
return xml.toString();
}
public ContainerProperty initializeFromNode(Realm realm, Node node) {
ContainerProperty containerProperty = new ContainerProperty();
String capacityValue = node.getAttributes().getNamedItem("capacity").getNodeValue();
containerProperty.setCapacity(Integer.parseInt(capacityValue));
for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
if (subNode.getNodeName().equals("Resource")) {
String resourceNameValue = subNode.getFirstChild().getNodeValue();
Resource resource = realm.getResourceManager().getResource(resourceNameValue);
containerProperty.addResource(resource);
} else if (subNode.getNodeName().equals("UnitType")) {
String unitTypeIdValue = subNode.getFirstChild().getNodeValue();
int unitTypeId = Integer.parseInt(unitTypeIdValue);
containerProperty.addUnitType(unitTypeId);
} else if (subNode.getNodeName().equals("Population")) {
containerProperty.setAccomodatingPopulation(true);
}
}
}
return containerProperty;
}