use of pl.themolka.arcade.dom.Cursor in project Arcade2 by ShootGame.
the class JDOMEngine method convert.
//
// Converting
//
public static Node convert(org.jdom2.Element jdom) {
List<Element> children = jdom.getChildren();
Node node = Node.of(JDOMEngine.convert(jdom.getNamespace()), jdom.getName());
String maybeValue = jdom.getValue();
if (children.isEmpty() && maybeValue != null) {
// primitive value
node.setValue(jdom.getValue());
} else {
// children
List<Node> parsed = new ArrayList<>();
for (org.jdom2.Element child : children) {
parsed.add(JDOMEngine.convert(child));
}
node.add(parsed);
}
// properties
for (org.jdom2.Attribute attribute : jdom.getAttributes()) {
node.setProperty(JDOMEngine.convert(attribute));
}
// location
if (jdom instanceof JDOMElement) {
JDOMElement located = (JDOMElement) jdom;
Cursor start = located.getStartCursor();
Cursor end = located.getEndCursor();
if (start != null && end != null) {
node.locate(start, end);
}
}
return node;
}