org.apache.myfaces.trinidad.model
Class RowKeySetImpl

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

public final class RowKeySetImpl
extends RowKeySet
implements java.io.Externalizable

Implements a set of rowKeys. This set is connected with a CollectionModel and is actually a subset of the rowKeys contained by the CollectionModel. This set is used to group together rows that have a common UI property. For example, all the rows that are currently selected by a user might be placed in a single RowKeySet.

This class has very efficient implementations for addAll, clear and invertAll.

See Also:
Serialized Form

Constructor Summary
RowKeySetImpl()
          Creates an initially empty RowKeySet.
RowKeySetImpl(boolean addAll)
          Creates a new RowKeySet.
 
Method Summary
 boolean add(java.lang.Object rowKey)
          Adds the current rowKey to this set.
 void addAll()
          Adds every rowKey to this set.
 boolean addAll(java.util.Collection<? extends java.lang.Object> c)
           
 void clear()
          Removes every rowKey from this set.
 RowKeySetImpl clone()
          Creates a shallow clone of this RowKeySet.
 boolean contains(java.lang.Object rowKey)
          Checks to see the current rowKey is contained by this set.
protected  CollectionModel getCollectionModel()
          Gets the CollectionModel associated with this set.
 int getSize()
          Gets the number of rowKeys in this set (if known).
 boolean invert(java.lang.Object rowKey)
          Adds the current rowKey to this set if it doesn't already exist, removes it otherwise.
 void invertAll()
          Inverts this set.
 boolean isContainedByDefault()
           
 boolean isEmpty()
           
 java.util.Iterator<java.lang.Object> iterator()
          Gets an iteration of all the rowKeys contained in this Set.
 void readExternal(java.io.ObjectInput in)
           
 boolean remove(java.lang.Object rowKey)
          Removes the current rowKey from this set.
 boolean removeAll(java.util.Collection<?> c)
           
 void setCollectionModel(CollectionModel model)
          Changes the underlying CollectionModel being used by this set.
 int size()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.apache.myfaces.trinidad.model.RowKeySet
add, invert, isContained, remove, removeAll, 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

RowKeySetImpl

public RowKeySetImpl()
Creates an initially empty RowKeySet.


RowKeySetImpl

public RowKeySetImpl(boolean addAll)
Creates a new RowKeySet.

Parameters:
addAll - whether to add every rowKey to this set.
Method Detail

contains

public boolean contains(java.lang.Object rowKey)
Checks to see the current rowKey is contained by this set.

Specified by:
contains in interface java.util.Collection<java.lang.Object>
Specified by:
contains in interface java.util.Set<java.lang.Object>
Overrides:
contains in class java.util.AbstractCollection<java.lang.Object>
Returns:
true if this set contains the current rowKey

add

public boolean add(java.lang.Object rowKey)
Adds the current rowKey to this set.

Specified by:
add in interface java.util.Collection<java.lang.Object>
Specified by:
add in interface java.util.Set<java.lang.Object>
Overrides:
add in class java.util.AbstractCollection<java.lang.Object>
Returns:
true if this set changed

remove

public boolean remove(java.lang.Object rowKey)
Removes the current rowKey from this set.

Specified by:
remove in interface java.util.Collection<java.lang.Object>
Specified by:
remove in interface java.util.Set<java.lang.Object>
Overrides:
remove in class java.util.AbstractCollection<java.lang.Object>
Returns:
true if this set changed

invert

public boolean invert(java.lang.Object rowKey)
Adds the current rowKey to this set if it doesn't already exist, removes it otherwise.

Overrides:
invert in class RowKeySet
Returns:
true if the row is now added. false otherwise.

invertAll

public void invertAll()
Inverts this set. All of the contents of this set will be removed. Then rowKeys that were not previously in this set will be added. This method executes in constant time.

Specified by:
invertAll in class RowKeySet

addAll

public void addAll()
Adds every rowKey to this set. This method executes in constant time.

Specified by:
addAll in class RowKeySet

isContainedByDefault

public boolean isContainedByDefault()
Specified by:
isContainedByDefault in class RowKeySet

clear

public void clear()
Removes every rowKey from this set. This method executes in constant time.

Specified by:
clear in interface java.util.Collection<java.lang.Object>
Specified by:
clear in interface java.util.Set<java.lang.Object>
Overrides:
clear in class java.util.AbstractCollection<java.lang.Object>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<java.lang.Object>
Specified by:
removeAll in interface java.util.Set<java.lang.Object>
Overrides:
removeAll in class java.util.AbstractSet<java.lang.Object>

addAll

public boolean addAll(java.util.Collection<? extends java.lang.Object> c)
Specified by:
addAll in interface java.util.Collection<java.lang.Object>
Specified by:
addAll in interface java.util.Set<java.lang.Object>
Overrides:
addAll in class java.util.AbstractCollection<java.lang.Object>

setCollectionModel

public final void setCollectionModel(CollectionModel model)
Changes the underlying CollectionModel being used by this set. The current rowKey (that is used by some of the methods in this class) is obtained from this CollectionModel.

Users typically do not need to call this method. This method is called by component writers who need to set the models used by their components on this set.

Specified by:
setCollectionModel in class RowKeySet

getSize

public int getSize()
Gets the number of rowKeys in this set (if known).

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

size

public int size()
Specified by:
size in interface java.util.Collection<java.lang.Object>
Specified by:
size in interface java.util.Set<java.lang.Object>
Specified by:
size in class java.util.AbstractCollection<java.lang.Object>

isEmpty

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

iterator

public java.util.Iterator<java.lang.Object> iterator()
Gets an iteration of all the rowKeys contained in this Set.

Specified by:
iterator in interface java.lang.Iterable<java.lang.Object>
Specified by:
iterator in interface java.util.Collection<java.lang.Object>
Specified by:
iterator in interface java.util.Set<java.lang.Object>
Specified by:
iterator in class java.util.AbstractCollection<java.lang.Object>
Returns:
each entry is a rowKey. The CollectionModel and this Set should not be mutated while the iterator is being used.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

clone

public RowKeySetImpl clone()
Creates a shallow clone of this RowKeySet. Keys may be added or removed from the clone without affecting this instance.

Overrides:
clone in class RowKeySet

getCollectionModel

protected CollectionModel getCollectionModel()
Gets the CollectionModel associated with this set. The current rowKey (that is used by some of the methods in this class) is obtained from this CollectionModel.

Specified by:
getCollectionModel in class RowKeySet
See Also:
RowKeySet.setCollectionModel(org.apache.myfaces.trinidad.model.CollectionModel)


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.