xml.append("</CityImprovement>");
return xml.toString();
}
public SettlementImprovementType initializeFromNode(Realm realm, Node node) {
SettlementImprovementTypeImpl cityImprovement = new SettlementImprovementTypeImpl();
String nameValue = node.getAttributes().getNamedItem("name").getNodeValue();
int productionCostValue = Integer.parseInt(node.getAttributes().getNamedItem("productionCost").getNodeValue());
int upkeepCostValue = Integer.parseInt(node.getAttributes().getNamedItem("upkeepCost").getNodeValue());
int idValue = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue());
cityImprovement.setName(nameValue);
cityImprovement.setProductionCost(productionCostValue);
cityImprovement.setUpkeepCost(upkeepCostValue);
cityImprovement.setId(idValue);
Node workersNode = XMLConverterUtility.findNode(node, "workers");
if (workersNode != null) {
int workers = Integer.parseInt(workersNode.getFirstChild().getNodeValue());
cityImprovement.setMaximumWorkers(workers);
}
for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
if (subNode.getNodeName().equals("Properties")) {
for (Node propertyNode = subNode.getFirstChild(); propertyNode != null; propertyNode = propertyNode.getNextSibling()) {
if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
Property property = PropertyFactory.createProperty(realm, propertyNode);
cityImprovement.addProperty(property);
}
}
}
}
}