Attribute (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) && (duplicate != index)) { throw new IllegalAddException("Cannot set duplicate attribute"); } final String reason = Verifier.checkNamespaceCollision(attribute, parent, index); if (reason != null) { throw new IllegalAddException(parent, attribute, reason); } final Attribute old = attributeData[index]; old.setParent(null); attributeData[index] = attribute; attribute.setParent(parent); return old; }