xml.append("</playerHistory>\n");
return xml.toString();
}
public PlayerHistory initializeFromNode(Realm realm, Node node) {
PlayerHistory playerHistory = new FreeRealmPlayerHistory();
Node playerIdNode = XMLConverterUtility.findNode(node, "playerId");
int playerId = Integer.parseInt(playerIdNode.getFirstChild().getNodeValue());
playerHistory.setPlayer(realm.getPlayerManager().getPlayer(playerId));
Node playerHistoryTurnsNode = XMLConverterUtility.findNode(node, "playerHistoryTurns");
for (Node playerTurnHistoryNode = playerHistoryTurnsNode.getFirstChild(); playerTurnHistoryNode != null; playerTurnHistoryNode = playerTurnHistoryNode.getNextSibling()) {
if (playerTurnHistoryNode.getNodeType() == Node.ELEMENT_NODE) {
PlayerTurnHistory playerTurnHistory = new FreeRealmPlayerTurnHistoryXMLConverter().initializeFromNode(realm, playerTurnHistoryNode);
playerHistory.addTurnHistory(playerTurnHistory);
}
}
return playerHistory;
}