/** * A Factory Method pattern which creates a BackedList implementation used * to store results of a filtered content query. * * @param <T> DOCUMENT ME! * @return DOCUMENT ME! */ protected <T extends Node> BackedList<T> createResultList() { return new BackedList<T>(this, contentList()); }
@Override public boolean addAll(int index, Collection<? extends T> collection) { ensureCapacity(size() + collection.size()); int count = size(); for (Iterator<? extends T> iter = collection.iterator(); iter.hasNext(); count--) { add(index++, iter.next()); } return count != 0; }
public List<Namespace> declaredNamespaces() { BackedList<Namespace> answer = createResultList(); // if (getNamespaceURI().length() > 0) { // // answer.addLocal(getNamespace()); // // } final Object contentShadow = content; if (contentShadow instanceof List) { List<Node> list = (List<Node>) contentShadow; for (Node node : list) { if (node instanceof Namespace) { answer.addLocal((Namespace) node); } } } else { if (contentShadow instanceof Namespace) { answer.addLocal((Namespace) contentShadow); } } return answer; }
/** * A Factory Method pattern which creates a BackedList implementation which * contains a single result * * @param <T> DOCUMENT ME! * @param result * DOCUMENT ME! * * @return DOCUMENT ME! */ protected <T extends Node> List<T> createSingleResultList(T result) { BackedList<T> list = new BackedList<T>(this, contentList(), 1); list.addLocal(result); return list; }
@Override public void add(int index, T node) { int size = size(); if (index < 0) { throw new IndexOutOfBoundsException("Index value: " + index + " is less than zero"); } else if (index > size) { throw new IndexOutOfBoundsException("Index value: " + index + " cannot be greater than " + "the size: " + size); } int realIndex; if (size == 0) { realIndex = branchContent.size(); } else if (index < size) { realIndex = branchContent.indexOf(get(index)); } else { realIndex = branchContent.indexOf(get(size - 1)) + 1; } branch.addNode(realIndex, node); super.add(index, node); }
public void add(int index, Object object) { int size = size(); if (index < 0) { throw new IndexOutOfBoundsException("Index value: " + index + " is less than zero"); } else if (index > size) { throw new IndexOutOfBoundsException("Index value: " + index + " cannot be greater than " + "the size: " + size); } int realIndex; if (size == 0) { realIndex = branchContent.size(); } else if (index < size) { realIndex = branchContent.indexOf(get(index)); } else { realIndex = branchContent.indexOf(get(size - 1)) + 1; } branch.addNode(realIndex, asNode(object)); super.add(index, object); }
public Object set(int index, Object object) { int realIndex = branchContent.indexOf(get(index)); if (realIndex < 0) { realIndex = (index == 0) ? 0 : Integer.MAX_VALUE; } if (realIndex < branchContent.size()) { branch.removeNode(asNode(get(index))); branch.addNode(realIndex, asNode(object)); } else { branch.removeNode(asNode(get(index))); branch.addNode(asNode(object)); } branch.childAdded(asNode(object)); return super.set(index, object); }
public Object remove(int index) { Object object = super.remove(index); if (object != null) { branch.removeNode(asNode(object)); } return object; }
@Override public T set(int index, T node) { int realIndex = branchContent.indexOf(get(index)); if (realIndex < 0) { realIndex = (index == 0) ? 0 : Integer.MAX_VALUE; } if (realIndex < branchContent.size()) { branch.removeNode(get(index)); branch.addNode(realIndex, node); } else { branch.removeNode(get(index)); branch.addNode(node); } branch.childAdded(node); return super.set(index, node); }
public void add(int index, Object object) { int size = size(); if (index < 0) { throw new IndexOutOfBoundsException("Index value: " + index + " is less than zero"); } else if (index > size) { throw new IndexOutOfBoundsException("Index value: " + index + " cannot be greater than " + "the size: " + size); } int realIndex; if (size == 0) { realIndex = branchContent.size(); } else if (index < size) { realIndex = branchContent.indexOf(get(index)); } else { realIndex = branchContent.indexOf(get(size - 1)) + 1; } branch.addNode(realIndex, asNode(object)); super.add(index, object); }
public Object set(int index, Object object) { int realIndex = branchContent.indexOf(get(index)); if (realIndex < 0) { realIndex = (index == 0) ? 0 : Integer.MAX_VALUE; } if (realIndex < branchContent.size()) { branch.removeNode(asNode(get(index))); branch.addNode(realIndex, asNode(object)); } else { branch.removeNode(asNode(get(index))); branch.addNode(asNode(object)); } branch.childAdded(asNode(object)); return super.set(index, object); }
/** * A Factory Method pattern which creates a BackedList implementation which * contains a single result * * @param result * DOCUMENT ME! * * @return DOCUMENT ME! */ protected List createSingleResultList(Object result) { BackedList list = new BackedList(this, contentList(), 1); list.addLocal(result); return list; }
@Override public void add(int index, T node) { int size = size(); if (index < 0) { throw new IndexOutOfBoundsException("Index value: " + index + " is less than zero"); } else if (index > size) { throw new IndexOutOfBoundsException("Index value: " + index + " cannot be greater than " + "the size: " + size); } int realIndex; if (size == 0) { realIndex = branchContent.size(); } else if (index < size) { realIndex = branchContent.indexOf(get(index)); } else { realIndex = branchContent.indexOf(get(size - 1)) + 1; } branch.addNode(realIndex, node); super.add(index, node); }
public Object remove(int index) { Object object = super.remove(index); if (object != null) { branch.removeNode(asNode(object)); } return object; }
@Override public T set(int index, T node) { int realIndex = branchContent.indexOf(get(index)); if (realIndex < 0) { realIndex = (index == 0) ? 0 : Integer.MAX_VALUE; } if (realIndex < branchContent.size()) { branch.removeNode(get(index)); branch.addNode(realIndex, node); } else { branch.removeNode(get(index)); branch.addNode(node); } branch.childAdded(node); return super.set(index, node); }
@Override public boolean addAll(Collection<? extends T> collection) { ensureCapacity(size() + collection.size()); int count = size(); for (Iterator<? extends T> iter = collection.iterator(); iter.hasNext(); count--) { add(iter.next()); } return count != 0; }
public void add(int index, Object object) { int size = size(); if (index < 0) { throw new IndexOutOfBoundsException("Index value: " + index + " is less than zero"); } else if (index > size) { throw new IndexOutOfBoundsException("Index value: " + index + " cannot be greater than " + "the size: " + size); } int realIndex; if (size == 0) { realIndex = branchContent.size(); } else if (index < size) { realIndex = branchContent.indexOf(get(index)); } else { realIndex = branchContent.indexOf(get(size - 1)) + 1; } branch.addNode(realIndex, asNode(object)); super.add(index, object); }
public List<Element> elements(String name) { BackedList<Element> answer = createResultList(); for (Node node : contentList()) { if (node instanceof Element) { Element element = (Element) node; if (name.equals(element.getName())) { answer.addLocal(element); } } } return answer; }