コード例 #1
0
 @Override
 protected Inventory createObjectForElement(Element element) throws InvalidObjectException {
   Inventory inventory = new Inventory();
   inventory.getItems().addAll(getSubObjects(element, m_itemXMLAdapter));
   inventory.getArmors().addAll(getSubObjects(element, m_armorXMLAdapter));
   inventory.getWeapons().addAll(getSubObjects(element, m_weaponXMLAdapter));
   return inventory;
 }
コード例 #2
0
  @Override
  protected void setElementContentForObject(Element element, Inventory inventory) {
    List<Item> items = inventory.getItems();
    for (Item item : items) {
      element.add(m_itemXMLAdapter.toXML(item));
    }

    List<Armor> armors = inventory.getArmors();
    for (Armor armor : armors) {
      element.add(m_armorXMLAdapter.toXML(armor));
    }

    List<Weapon> weapons = inventory.getWeapons();
    for (Weapon weapon : weapons) {
      element.add(m_weaponXMLAdapter.toXML(weapon));
    }
  }