void clearAndSet(final Collection<? extends Attribute> collection) {
		if (collection == null || collection.isEmpty()) {
			clear();
			return;
		}

		// keep a backup in case we need to roll-back...
		final Attribute[] old = attributeData;
		final int oldSize = size;
		final int oldModCount = modCount;

		// clear the current system
		// we need to detatch before we add so that we don't run in to a problem
		// where an attribute in the to-add list is one that we are 'clearing'
		// first.
		while (size > 0) {
			old[--size].setParent(null);
		}
		size = 0;
		attributeData = null;

		boolean ok = false;
		try {
			addAll(0, collection);
			ok = true;
		} finally {
			if (!ok) {
				// we have an exception pending....
				// restore the old system.
				// re-attach the old stuff
				attributeData = old;
				while (size < oldSize) {
					attributeData[size++].setParent(parent);
				}
				modCount = oldModCount;
			}
		}

	}