Gridarta Editor
TreasureListsParser.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.treasurelist;
21 
22 import java.util.HashMap;
23 import java.util.Map;
25 import nu.xom.Document;
26 import nu.xom.Element;
27 import org.jetbrains.annotations.NotNull;
28 
33 public class TreasureListsParser {
34 
38  private TreasureListsParser() {
39  }
40 
49  @NotNull
50  public static Map<String, TreasureTreeNode> parseTreasureLists(@NotNull final Document specialTreasureListsDocument) {
51  final Element rootElement = specialTreasureListsDocument.getRootElement();
52  assert rootElement != null && rootElement.getLocalName().equalsIgnoreCase("lists");
53 
54  final Map<String, TreasureTreeNode> specialTreasureLists = new HashMap<>();
55  for (final Element list : new ElementsIterable(rootElement.getChildElements("list"))) {
56  final String listName = list.getAttribute("name").getValue();
57  assert listName != null;
58 
59  final TreasureTreeNode folder = new TreasureTreeNode(new FolderTreasureObj(listName));
60 
61  for (final Element entry : new ElementsIterable(list.getChildElements("entry"))) {
62  final String entryName = entry.getAttribute("name").getValue();
63  assert entryName != null;
64 
65  specialTreasureLists.put(entryName, folder);
66  }
67  }
68 
69  return specialTreasureLists;
70  }
71 
72 }
net.sf.gridarta.model.treasurelist.TreasureTreeNode
Definition: TreasureTreeNode.java:33
net.sf.gridarta
net.sf
net.sf.gridarta.model.treasurelist.TreasureListsParser.parseTreasureLists
static Map< String, TreasureTreeNode > parseTreasureLists(@NotNull final Document specialTreasureListsDocument)
Definition: TreasureListsParser.java:50
net.sf.gridarta.model.treasurelist.TreasureListsParser.TreasureListsParser
TreasureListsParser()
Definition: TreasureListsParser.java:38
net
net.sf.gridarta.utils.xml.ElementsIterable
Definition: ElementsIterable.java:30
net.sf.gridarta.model.treasurelist.TreasureListsParser
Definition: TreasureListsParser.java:33
net.sf.gridarta.utils.xml
Definition: ElementsIterable.java:20
net.sf.gridarta.model.treasurelist.FolderTreasureObj
Definition: FolderTreasureObj.java:28
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20