org.norther.tammi.acorn.util
Class ModifiableSet

java.lang.Object
  extended by org.norther.tammi.acorn.util.UnmodifiableCollection
      extended by org.norther.tammi.acorn.util.UnmodifiableSet
          extended by org.norther.tammi.acorn.util.ModifiableSet
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Set, OrderedSet

public class ModifiableSet
extends UnmodifiableSet

Extends UnmodifiableSet by supporting modifications after cloning.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ModifiableSet(boolean modifiable)
          Constructs an empty set.
ModifiableSet(Collection c, boolean modifiable)
          Constructs a new set for a collection.
ModifiableSet(Set s, boolean modifiable)
          Constructs a new set.
 
Method Summary
 boolean add(int index, Object o)
          Adds the specified element to the specified index in this set.
 Object clone()
           
 boolean isModifiable()
          Checks whether this set is modifiable.
 ListIterator listIterator()
          Returns a list iterator over the elements in this set.
 ListIterator listIterator(int index)
          Returns a list iterator with a start index over the elements in this set.
 Object remove(int index)
          Removes the indexed element in this set.
protected  void setCollection(Collection c)
          Sets the collection adaptee.
 List valueList()
          Returns an ordered list of set values.
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableSet
get, getSet, indexOf, setSet
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableCollection
add, addAll, clear, contains, containsAll, equals, getCollection, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.acorn.util.OrderedSet
iterator
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

ModifiableSet

public ModifiableSet(boolean modifiable)
Constructs an empty set.

Parameters:
modifiable - true to clone automatically during modifications, false to allow modifications only after cloning.

ModifiableSet

public ModifiableSet(Set s,
                     boolean modifiable)
Constructs a new set.

Parameters:
s - a set to wrap.
modifiable - true to clone automatically during modifications, false to allow modifications only after cloning.

ModifiableSet

public ModifiableSet(Collection c,
                     boolean modifiable)
Constructs a new set for a collection.

Parameters:
c - a collection to wrap.
modifiable - true to clone automatically during modifications, false to allow modifications only after cloning.
Method Detail

clone

public Object clone()
Overrides:
clone in class UnmodifiableCollection

isModifiable

public boolean isModifiable()
Description copied from interface: OrderedSet
Checks whether this set is modifiable.

Specified by:
isModifiable in interface OrderedSet
Overrides:
isModifiable in class UnmodifiableSet
Returns:
true for a modifiable set, false otherwise.

add

public boolean add(int index,
                   Object o)
Description copied from interface: OrderedSet
Adds the specified element to the specified index in this set. Note that an existing element is not moved.

Specified by:
add in interface OrderedSet
Overrides:
add in class UnmodifiableSet
Parameters:
index - the index.
o - the element.
Returns:
true if added, false if already present.

remove

public Object remove(int index)
Description copied from interface: OrderedSet
Removes the indexed element in this set.

Specified by:
remove in interface OrderedSet
Overrides:
remove in class UnmodifiableSet
Parameters:
index - the index.
Returns:
the removed value.

listIterator

public ListIterator listIterator()
Description copied from interface: OrderedSet
Returns a list iterator over the elements in this set.

Specified by:
listIterator in interface OrderedSet
Overrides:
listIterator in class UnmodifiableSet
Returns:
a list iterator.

listIterator

public ListIterator listIterator(int index)
Description copied from interface: OrderedSet
Returns a list iterator with a start index over the elements in this set.

Specified by:
listIterator in interface OrderedSet
Overrides:
listIterator in class UnmodifiableSet
Parameters:
index - the start index.
Returns:
a list iterator.

valueList

public List valueList()
Description copied from interface: OrderedSet
Returns an ordered list of set values.

Specified by:
valueList in interface OrderedSet
Overrides:
valueList in class UnmodifiableSet
Returns:
a list of values.

setCollection

protected void setCollection(Collection c)
Description copied from class: UnmodifiableCollection
Sets the collection adaptee.

Overrides:
setCollection in class UnmodifiableSet
Parameters:
c - the wrapped collection.


Copyright © 2004 The Norther Organization. All rights reserved.