org.norther.tammi.acorn.util
Class ModifiableOrderedSet<E>

java.lang.Object
  extended by org.norther.tammi.acorn.util.UnmodifiableCollection<E>
      extended by org.norther.tammi.acorn.util.UnmodifiableSet<E>
          extended by org.norther.tammi.acorn.util.UnmodifiableOrderedSet<E>
              extended by org.norther.tammi.acorn.util.ModifiableOrderedSet<E>
Type Parameters:
E - the element type.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>, Modifiable, OrderedSet<E>

public class ModifiableOrderedSet<E>
extends UnmodifiableOrderedSet<E>
implements Modifiable

Extends UnmodifiableOrderedSet by supporting modifications after cloning.

Version:
$Id: ModifiableOrderedSet.java,v 1.2 2009/09/28 15:08:48 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.acorn.util.Modifiable
MODIFIABLE_ADAPTEE, MODIFIABLE_ADAPTER, MODIFIABLE_COLLECTION, MODIFIABLE_MASK
 
Constructor Summary
ModifiableOrderedSet(boolean... modifiable)
          Constructs an empty set.
ModifiableOrderedSet(Collection<E> c, boolean... modifiable)
          Constructs a new set for a collection.
ModifiableOrderedSet(OrderedSet<E> s, boolean... modifiable)
          Constructs a new set.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(Collection<? extends E> x)
           
 boolean addAt(int index, E o)
          Adds the specified element at the specified index in this set.
 void clear()
           
 Object clone()
           
protected  OrderedSet<E> getModifiableSet(boolean... modifiable)
          Gets a modifiable instance of the wrapped set.
 boolean isModifiable()
          Checks whether this set is modifiable.
 Iterator<E> iterator()
          Returns an ordered iterator over the elements in this set.
 ListIterator<E> listIterator()
          Returns a list iterator over the elements in this set.
 ListIterator<E> listIterator(int index)
          Returns a list iterator with a start index over the elements in this set.
 E removeAt(int index)
          Removes the indexed element in this set.
 E set(int index, E o)
          Sets the specified element at the specified index in this set.
protected  void setCollection(Collection<E> c)
          Sets the collection adaptee.
 E shift(int index, E o)
          Shifts the specified element to the specified index in this set.
 List<E> valueList()
          Returns an ordered list of set values.
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableOrderedSet
addAll, get, getSet, indexOf
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableSet
setSet
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableCollection
contains, containsAll, equals, getCollection, hashCode, isEmpty, 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 java.util.Set
contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

ModifiableOrderedSet

public ModifiableOrderedSet(boolean... modifiable)
Constructs an empty set.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.

ModifiableOrderedSet

public ModifiableOrderedSet(OrderedSet<E> s,
                            boolean... modifiable)
Constructs a new set.

Parameters:
s - a set to wrap.
modifiable - the modifiable states of the collection, adapter and adaptee.

ModifiableOrderedSet

public ModifiableOrderedSet(Collection<E> c,
                            boolean... modifiable)
Constructs a new set for a collection.

Parameters:
c - a collection to wrap.
modifiable - the modifiable states of the collection, adapter and adaptee.
Method Detail

clone

public Object clone()
Overrides:
clone in class UnmodifiableCollection<E>

isModifiable

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

Specified by:
isModifiable in interface Modifiable
Specified by:
isModifiable in interface OrderedSet<E>
Overrides:
isModifiable in class UnmodifiableOrderedSet<E>
Returns:
true for a modifiable set, false otherwise.

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class UnmodifiableCollection<E>

addAll

public boolean addAll(Collection<? extends E> x)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class UnmodifiableCollection<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class UnmodifiableCollection<E>

set

public E set(int index,
             E o)
Description copied from interface: OrderedSet
Sets the specified element at the specified index in this set. An existing element is moved to the indexed position whereas a new one replaces the previous element at the same index.

Specified by:
set in interface OrderedSet<E>
Overrides:
set in class UnmodifiableOrderedSet<E>
Parameters:
index - the index.
o - the element.
Returns:
the removed element or null.

shift

public E shift(int index,
               E o)
Description copied from interface: OrderedSet
Shifts the specified element to the specified index in this set.

Specified by:
shift in interface OrderedSet<E>
Overrides:
shift in class UnmodifiableOrderedSet<E>
Parameters:
index - the index.
o - the element.
Returns:
the shifted element or null.

addAt

public boolean addAt(int index,
                     E o)
Description copied from interface: OrderedSet
Adds the specified element at the specified index in this set.

Specified by:
addAt in interface OrderedSet<E>
Overrides:
addAt in class UnmodifiableOrderedSet<E>
Parameters:
index - the index.
o - the element.
Returns:
true if added, false if already present.

removeAt

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

Specified by:
removeAt in interface OrderedSet<E>
Overrides:
removeAt in class UnmodifiableOrderedSet<E>
Parameters:
index - the index.
Returns:
the removed value.

iterator

public Iterator<E> iterator()
Description copied from interface: OrderedSet
Returns an ordered iterator over the elements in this set.

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in interface OrderedSet<E>
Overrides:
iterator in class UnmodifiableCollection<E>
Returns:
an iterator.

listIterator

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

Specified by:
listIterator in interface OrderedSet<E>
Overrides:
listIterator in class UnmodifiableOrderedSet<E>
Returns:
a list iterator.

listIterator

public ListIterator<E> 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<E>
Overrides:
listIterator in class UnmodifiableOrderedSet<E>
Parameters:
index - the start index.
Returns:
a list iterator.

valueList

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

Specified by:
valueList in interface OrderedSet<E>
Overrides:
valueList in class UnmodifiableOrderedSet<E>
Returns:
a list of values.

setCollection

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

Overrides:
setCollection in class UnmodifiableOrderedSet<E>
Parameters:
c - the wrapped collection.

getModifiableSet

protected OrderedSet<E> getModifiableSet(boolean... modifiable)
Gets a modifiable instance of the wrapped set.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.
Returns:
a modifiable set or null.


Copyright © 2004 The Norther Organization. All rights reserved.