xml.append("</ResourceStorage>");
return xml.toString();
}
public ResourceStorageManager initializeFromNode(Realm realm, Node node) {
ResourceStorageManager resourceStorageManager = new ResourceStorageManager(realm);
for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
Node resourceIdNode = XMLConverterUtility.findNode(subNode, "resourceId");
Node resourceQuantityNode = XMLConverterUtility.findNode(subNode, "resourceQuantity");
int resourceId = Integer.parseInt(resourceIdNode.getFirstChild().getNodeValue());
int resourceQuantity = Integer.parseInt(resourceQuantityNode.getFirstChild().getNodeValue());
Resource resource = realm.getResourceManager().getResource(resourceId);
resourceStorageManager.setResourceQuantity(resource, resourceQuantity);
}
}
return resourceStorageManager;
}