20 package net.sf.gridarta.model.spells;
25 import nu.xom.Document;
26 import nu.xom.Element;
27 import org.apache.log4j.Category;
28 import org.apache.log4j.Logger;
29 import org.jetbrains.annotations.NotNull;
57 final Element root = document.getRootElement();
58 if (root == null || !root.getLocalName().equals(
"spells")) {
63 for (
final Element spellElem :
new ElementsIterable(root.getChildElements(
"spell"))) {
64 if (spellElem.getAttribute(
"id") == null) {
66 }
else if (spellElem.getAttribute(
"name") == null) {
71 spells.add(
new NumberSpell(spellElem.getAttribute(
"name").getValue().trim(), Integer.parseInt(spellElem.getAttribute(
"id").getValue())));
73 }
catch (
final NumberFormatException ignored) {
80 if (LOG.isInfoEnabled()) {
81 LOG.info(
"Loaded " + numSpells +
" defined spells.");
Convenience class for adding messages to a ErrorView instance using a fixed category name...
Describes a numbered in-game spell.
Defines possible error categories for ErrorView instances.
Base package of all Gridarta classes.
Common base class for spells and spell lists.
Load spell definitions from an XML file.
static void load(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Document document, @NotNull final Spells< NumberSpell > spells)
Load an XML spell definitions file.
static final Category LOG
The Logger for printing log messages.
XMLSpellLoader()
Private constructor to prevent instantiation.