org.norther.tammi.acorn.util
Class UnmodifiableSet

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

public class UnmodifiableSet
extends UnmodifiableCollection
implements OrderedSet

An unmodifiable set wrapper filtering out additions and removals.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
UnmodifiableSet()
          Constructs an empty set.
UnmodifiableSet(Collection c)
          Constructs a new set for a collection.
UnmodifiableSet(Set s)
          Constructs a new set.
 
Method Summary
 boolean add(int index, Object o)
          Adds the specified element to the specified index in this set.
 Object get(int index)
          Gets the indexed element in this set.
protected  Set getSet()
          Gets the set adaptee.
 int indexOf(Object o)
          Returns the index of the specified element, or -1 if not found.
 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.
protected  void setSet(Set s)
          Sets the set adaptee.
 List valueList()
          Returns an ordered list of set values.
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableCollection
add, addAll, clear, clone, 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

UnmodifiableSet

public UnmodifiableSet()
Constructs an empty set.


UnmodifiableSet

public UnmodifiableSet(Set s)
Constructs a new set.

Parameters:
s - a set to wrap.

UnmodifiableSet

public UnmodifiableSet(Collection c)
Constructs a new set for a collection.

Parameters:
c - a collection to wrap.
Method Detail

isModifiable

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

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

indexOf

public int indexOf(Object o)
Description copied from interface: OrderedSet
Returns the index of the specified element, or -1 if not found.

Specified by:
indexOf in interface OrderedSet
Parameters:
o - the element.
Returns:
the index of the element.

get

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

Specified by:
get in interface OrderedSet
Parameters:
index - the index.
Returns:
the indexed the element.

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
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
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
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
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
Returns:
a list of values.

getSet

protected Set getSet()
Gets the set adaptee.

Returns:
the wrapped set.

setSet

protected void setSet(Set s)
Sets the set adaptee.

Parameters:
s - the wrapped set.

setCollection

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

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


Copyright © 2004 The Norther Organization. All rights reserved.