public Profile(Element el) { name = el.getAttribute("name"); ids = new HashSet<String>(); Node child = el.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { ids.add(((Element) child).getAttribute("id")); } child = child.getNextSibling(); } }
public void appendTo(Element el) { Document doc = el.getOwnerDocument(); Element p = doc.createElement("profile"); p.setAttribute("name", name); Iterator<String> it = ids.iterator(); while (it.hasNext()) { Element child = doc.createElement("enable"); child.setAttribute("id", it.next()); p.appendChild(child); } el.appendChild(p); }
public boolean has(String id) { return ids.contains(id); }
public void add(String id) { ids.add(id); }