void (final int index, final Attribute attribute) { if (index < 0 || index > size) { throw new IndexOutOfBoundsException("Index: " + index + " Size: " + size()); } if (attribute.getParent() != null) { throw new IllegalAddException( "The attribute already has an existing parent \"" + attribute.getParent().getQualifiedName() + "\""); } final int duplicate = indexOfDuplicate(attribute); if (duplicate >= 0) { throw new IllegalAddException("Cannot add duplicate attribute"); } final String reason = Verifier.checkNamespaceCollision(attribute, parent); if (reason != null) { throw new IllegalAddException(parent, attribute, reason); } attribute.setParent(parent); ensureCapacity(size + 1); if (index == size) { attributeData[size++] = attribute; } else { System.arraycopy(attributeData, index, attributeData, index + 1, size - index); attributeData[index] = attribute; size++; } modCount++; }