How to Copy a Container?

Hi everybody,

is there a way to copy/clon a container with all its itemes?!

	public IndexedContainer copyContainer(Container source) {
		IndexedContainer cont = new IndexedContainer();
		
		for (Object prop : source.getContainerPropertyIds())
			cont.addContainerProperty(prop, source.getType(prop), null);
		
		for (Object id : source.getItemIds()) {
			Item sourceItem = source.getItem(id);
			Item destItem = cont.addItem(id);
			for (Object prop : source.getContainerPropertyIds()) {
				Object value = sourceItem.getItemProperty(prop).getValue();
				destItem.getItemProperty(prop).setValue(value);
			}
		}
		
		return cont;
	}

Try this, not tested, but you should get the idea.

@ Ovil Hemeke: Worked out perfectly for me - thanks!