org.apache.myfaces.trinidad.model
Class RowKeySetTreeImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Object>
          extended by org.apache.myfaces.trinidad.model.RowKeySet
              extended by org.apache.myfaces.trinidad.model.RowKeySetTreeImpl
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, Set<Object>

public class RowKeySetTreeImpl
extends RowKeySet
implements Serializable

Implements a collection of rowKeys from a TreeModel. The methods on this class are optimized such that it is possible to add/remove all the rowkeys in a subtree in constant time.

The generic type E is the type of a rowKey.

See Also:
Serialized Form

Constructor Summary
RowKeySetTreeImpl()
          Creates a new Set that is initially empty.
RowKeySetTreeImpl(boolean addAll)
          Creates a new Set, that may contain every rowKey by default.
 
Method Summary
 boolean add(Object rowKey)
          Adds the given rowKey to this Set.
 void addAll()
          Adds the current rowKey and all rowKeys beneath the current rowKey to this Set.
 boolean addAll(Collection<? extends Object> other)
          
 void clear()
          Removes all rowKeys from this Set.
 RowKeySetTreeImpl clone()
          Creates a clone of this Set.
 boolean contains(Object rowKey)
          Tests to see if the given rowKey is included in this Set.
protected  TreeModel getCollectionModel()
          Gets the TreeModel associated with this set.
 int getSize()
          Gets the number of elements contained by this set.
 void invertAll()
          Deprecated. not implemented.
 boolean isContainedByDefault()
          Deprecated. do not use. this will be removed post Tier 1.
 boolean isEmpty()
           
 Iterator<Object> iterator()
           
 boolean remove(Object rowKey)
          Removes the given rowKey from this Set.
 void removeAll()
          Removes the current rowKey and all rowKeys beneath the current rowKey to this Set.
 boolean removeAll(Collection<?> other)
          
 void setCollectionModel(CollectionModel model)
          Sets the TreeModel associated with this Set.
 int size()
          Gets the number of elements in this Set.
 
Methods inherited from class org.apache.myfaces.trinidad.model.RowKeySet
add, invert, invert, isContained, remove, setContained
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, retainAll, toArray, toArray
 

Constructor Detail

RowKeySetTreeImpl

public RowKeySetTreeImpl()
Creates a new Set that is initially empty.


RowKeySetTreeImpl

public RowKeySetTreeImpl(boolean addAll)
Creates a new Set, that may contain every rowKey by default.

Parameters:
addAll - if this is true, every rowKey is initially added to this set.
Method Detail

contains

public boolean contains(Object rowKey)
Tests to see if the given rowKey is included in this Set.

Specified by:
contains in interface Collection<Object>
Specified by:
contains in interface Set<Object>
Overrides:
contains in class AbstractCollection<Object>
Returns:
true If the rowKey is included in this Set.

isContainedByDefault

@Deprecated
public boolean isContainedByDefault()
Deprecated. do not use. this will be removed post Tier 1.

Specified by:
isContainedByDefault in class RowKeySet

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable<Object>
Specified by:
iterator in interface Collection<Object>
Specified by:
iterator in interface Set<Object>
Specified by:
iterator in class AbstractCollection<Object>

add

public boolean add(Object rowKey)
Adds the given rowKey to this Set.

Specified by:
add in interface Collection<Object>
Specified by:
add in interface Set<Object>
Overrides:
add in class AbstractCollection<Object>
Returns:
false if the given rowKey was already in this Set.
See Also:
remove(Object), addAll()

remove

public boolean remove(Object rowKey)
Removes the given rowKey from this Set.

Specified by:
remove in interface Collection<Object>
Specified by:
remove in interface Set<Object>
Overrides:
remove in class AbstractCollection<Object>
Returns:
false if the given rowKey was already not in this Set.
See Also:
add(java.lang.Object), removeAll()

addAll

public void addAll()
Adds the current rowKey and all rowKeys beneath the current rowKey to this Set. This method executes in constant time.

Specified by:
addAll in class RowKeySet
See Also:
add(java.lang.Object), removeAll()

removeAll

public void removeAll()
Removes the current rowKey and all rowKeys beneath the current rowKey to this Set. This method executes in constant time.

Overrides:
removeAll in class RowKeySet
See Also:
remove(Object), clear(), addAll()

addAll

public boolean addAll(Collection<? extends Object> other)

If the parameter is another RowKeySetTreeImpl, this method is optimized to give superior performance and avoid iteration.

Specified by:
addAll in interface Collection<Object>
Specified by:
addAll in interface Set<Object>
Overrides:
addAll in class AbstractCollection<Object>

removeAll

public boolean removeAll(Collection<?> other)

If the parameter is another RowKeySetTreeImpl, this method is optimized to give superior performance and avoid iteration.

Specified by:
removeAll in interface Collection<Object>
Specified by:
removeAll in interface Set<Object>
Overrides:
removeAll in class AbstractSet<Object>

clear

public void clear()
Removes all rowKeys from this Set. This method executes in the same time as HashMap.clear()

Specified by:
clear in interface Collection<Object>
Specified by:
clear in interface Set<Object>
Overrides:
clear in class AbstractCollection<Object>

getSize

public int getSize()
Gets the number of elements contained by this set. Does not force the underlying model to compute its size.

Overrides:
getSize in class RowKeySet
Returns:
-1 if the number of elements is unknown.

size

public int size()
Gets the number of elements in this Set. This might force the underlying model to compute its size.

Specified by:
size in interface Collection<Object>
Specified by:
size in interface Set<Object>
Specified by:
size in class AbstractCollection<Object>
Returns:
a non-negative number.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<Object>
Specified by:
isEmpty in interface Set<Object>
Overrides:
isEmpty in class AbstractCollection<Object>

setCollectionModel

public final void setCollectionModel(CollectionModel model)
Sets the TreeModel associated with this Set.

Specified by:
setCollectionModel in class RowKeySet
Parameters:
model - This must be of type TreeModel

clone

public RowKeySetTreeImpl clone()
Creates a clone of this Set. RowKeys may be added/removed from the clone without affecting this instance.

Overrides:
clone in class RowKeySet

invertAll

@Deprecated
public void invertAll()
Deprecated. not implemented.

Description copied from class: RowKeySet
Inverts this Set. Every element that is in this Set is removed, and every element that is not in this Set is added to this Set.

For List models, this method operates on the entire List. For tree models, this method only operates on the current subtree.

Specified by:
invertAll in class RowKeySet

getCollectionModel

protected TreeModel getCollectionModel()
Gets the TreeModel associated with this set. This TreeModel will be used to get the current rowKey, and also to get parent rowKeys, from child rowKeys.

Specified by:
getCollectionModel in class RowKeySet
See Also:
CollectionModel.getRowKey()


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.