FileDocCategorySizeDatePackage
FreezableList.javaAPI DocJava SE 5 API2732Fri Aug 26 14:54:22 BST 2005com.sun.corba.se.impl.ior

FreezableList

public class FreezableList extends AbstractList
Simple class that delegates all List operations to another list. It also can be frozen, which means that a number of operations can be performed on the list, and then the list can be made immutable, so that no further changes are possible. A FreezableList is frozen using the makeImmutable method.

Fields Summary
private List
delegate
private boolean
immutable
Constructors Summary
public FreezableList(List delegate, boolean immutable)

	this.delegate = delegate ;
	this.immutable = immutable ;
    
public FreezableList(List delegate)

	this( delegate, false ) ;
    
Methods Summary
public voidadd(int index, java.lang.Object element)

	if (immutable)
	    throw new UnsupportedOperationException() ;

	delegate.add(index, element) ;
    
public booleanequals(java.lang.Object obj)


         
    
	if (obj == null)
	    return false ;

	if (!(obj instanceof FreezableList))
	    return false ;

	FreezableList other = (FreezableList)obj ;

	return delegate.equals( other.delegate ) &&
	    (immutable == other.immutable) ;
    
public java.lang.Objectget(int index)

	return delegate.get(index) ;
    
public inthashCode()

	return delegate.hashCode() ;
    
public booleanisImmutable()

	return immutable ;
    
public voidmakeElementsImmutable()

	Iterator iter = iterator() ;
	while (iter.hasNext()) {
	    Object obj = iter.next() ;
	    if (obj instanceof MakeImmutable) {
		MakeImmutable element = (MakeImmutable)obj ;
		element.makeImmutable() ;
	    }
	}
    
public voidmakeImmutable()

	immutable = true ;
    
public java.lang.Objectremove(int index)

	if (immutable)
	    throw new UnsupportedOperationException() ;

	return delegate.remove(index) ;
    
public java.lang.Objectset(int index, java.lang.Object element)

	if (immutable)
	    throw new UnsupportedOperationException() ;

	return delegate.set(index, element) ;
    
public intsize()

	return delegate.size() ;
    
public java.util.ListsubList(int fromIndex, int toIndex)

	List list = delegate.subList(fromIndex, toIndex) ;
	List result = new FreezableList( list, immutable ) ;
	return result ;