List of usage examples for org.jdom2 Element isRootElement
public boolean isRootElement()
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
public static String deriveInputParamId(ParamStore store, Element element) { if (element.isRootElement()) return ""; Stack<String> shoppedIdStack = createStack(element); String id = shoppedIdStack.pop(); String value, nextId;//from www . j av a 2s .c o m while (!shoppedIdStack.isEmpty()) { value = shoppedIdStack.pop(); nextId = shoppedIdStack.pop(); if (value == null) { id += "." + nextId; } else if (store.containsParam(id + "." + value)) { // the param exists, value is not an index if (store.containsParam(id + "." + value + "." + nextId)) { // if this exists, we know that the param is a child of the next id entry. id += "." + value + "." + nextId; } else { id += "." + nextId; } } } return id; }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
private static Stack<String> createStack(Element element) { Stack<String> stack = new Stack<String>(); stack.push(element.getAttributeValue(Q.ID_ATTR)); Element current = element.getParentElement(); while (!current.isRootElement()) { stack.push(current.getAttributeValue(Q.VALUE_ATTR)); stack.push(current.getAttributeValue(Q.ID_ATTR)); current = current.getParentElement(); }/* ww w.j a va 2s . c o m*/ return stack; }
From source file:se.miun.itm.input.util.ParamUtil.java
License:Open Source License
public static String getParentId(Param<?> param) { Element parent = param.getParentElement(); if (parent.isRootElement()) return ""; if (parent instanceof SChoice) return ((Param<?>) parent.getParentElement()).getId(); return ((Param<?>) parent).getId(); }