Example usage for org.dom4j Element elementIterator

List of usage examples for org.dom4j Element elementIterator

Introduction

In this page you can find the example usage for org.dom4j Element elementIterator.

Prototype

Iterator<Element> elementIterator(QName qName);

Source Link

Document

Returns an iterator over the elements contained in this element which match the given fully qualified name.

Usage

From source file:lineage2.gameserver.data.xml.parser.SpawnParser.java

License:Open Source License

/**
 * Method parseTerritory./*from w w w.  jav  a 2  s. co m*/
 * @param name String
 * @param e Element
 * @return Territory
 */
private Territory parseTerritory(String name, Element e) {
    Territory t = new Territory();
    t.add(parsePolygon0(name, e));

    for (Iterator<Element> iterator = e.elementIterator("banned_territory"); iterator.hasNext();) {
        t.addBanned(parsePolygon0(name, iterator.next()));
    }

    return t;
}

From source file:lineage2.gameserver.data.xml.parser.SpawnParser.java

License:Open Source License

/**
 * Method parsePolygon0.//from  ww  w .j  ava2s .  c  om
 * @param name String
 * @param e Element
 * @return Polygon
 */
private Polygon parsePolygon0(String name, Element e) {
    Polygon temp = new Polygon();

    for (Iterator<Element> addIterator = e.elementIterator("add"); addIterator.hasNext();) {
        Element addElement = addIterator.next();
        int x = Integer.parseInt(addElement.attributeValue("x"));
        int y = Integer.parseInt(addElement.attributeValue("y"));
        int zmin = Integer.parseInt(addElement.attributeValue("zmin"));
        int zmax = Integer.parseInt(addElement.attributeValue("zmax"));
        temp.add(x, y).setZmin(zmin).setZmax(zmax);
    }

    if (!temp.validate()) {
        error("Invalid polygon: " + name + "{" + temp + "}. File: " + getCurrentFileName());
    }

    return temp;
}