/** * Insert an empty child. Will shift all children having an index * greater than or equal to the child inserted to the right. * @param nameIndex position where child is inserted */ public void insert(Path.PathElement nameIndex) { // convert 1-based index value to 0-base value int index = getZeroBasedIndex(nameIndex); if (children != null) { ArrayList list = (ArrayList) children.get(nameIndex.getName()); if (list != null && list.size() > index) { for (int i = index; i < list.size(); i++) { Element element = (Element) list.get(i); if (element != null) { element.index = element.getNormalizedIndex() + 1; } } list.add(index, null); } } }