private boolean canTransferAttribute(String attr, java.util.List attrList) { if (attrList == null || attrList.isEmpty()) return true; for (java.util.Iterator it = attrList.iterator(); it.hasNext(); ) { if (it.next().equals(attr)) return false; } return true; }
protected boolean isValidAttributeToTransfer(String attrName, java.util.List attrList) { for (java.util.Iterator it = attrList.iterator(); it.hasNext(); ) { if (((String) it.next()).equals(attrName)) { return true; } } return false; }
public void appendElementToParent(Element parentEle, Element element) { java.util.List eleStructureList = this.getInsertElementStructure(element, parentEle); if (eleStructureList == null) { // insert the element at the end parentEle.appendChild(element); return; } if (eleStructureList.isEmpty()) { // insert the element in the beginning. parentEle.insertBefore(element, parentEle.getFirstChild()); return; } String insertBeforeElementName = null; Node insertBeforeNode = null; for (int eleIndex = 0; eleIndex < eleStructureList.size(); eleIndex++) { insertBeforeElementName = (String) eleStructureList.get(eleIndex); Node lNode = parentEle.getFirstChild(); while (lNode != null) { if (lNode instanceof Element) { Element lElement = (Element) lNode; if (lElement.getNodeName().equals(insertBeforeElementName)) { // if match is found, break and insert insertBeforeNode = lNode; break; } } // go to next sibling in order lNode = lNode.getNextSibling(); } if (insertBeforeNode != null) { break; } } // if match is not found, node will be place at the end parentEle.insertBefore(element, insertBeforeNode); }