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 Map<String, TreasureTreeNode> specialTreasureLists = new HashMap<>();
52 
53  final Element rootElement = specialTreasureListsDocument.getRootElement();
54  assert rootElement != null && rootElement.getLocalName().equalsIgnoreCase("lists");
55 
56  for (final Element list : new ElementsIterable(rootElement.getChildElements("list"))) {
57  final String listName = list.getAttribute("name").getValue();
58  assert listName != null;
59 
60  final TreasureTreeNode folder = new TreasureTreeNode(new FolderTreasureObj(listName));
61 
62  for (final Element entry : new ElementsIterable(list.getChildElements("entry"))) {
63  final String entryName = entry.getAttribute("name").getValue();
64  assert entryName != null;
65 
66  specialTreasureLists.put(entryName, folder);
67  }
68  }
69 
70  return specialTreasureLists;
71  }
72 
73 }
TreasureListsParser()
Private constructor to prevent instantiation.
Base package of all Gridarta classes.
Utility class for loadings the TreasureLists.xml file.
static Map< String, TreasureTreeNode > parseTreasureLists(@NotNull final Document specialTreasureListsDocument)
This method fills the &#39;specialTreasureLists&#39; hash table with the names of all treasurelists which are...
Subclass: Nodes in the CFTreasureListTree.