org.apache.myfaces.trinidad.model

## Class RowKeySetImpl

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractSet<Object>
    - - org.apache.myfaces.trinidad.model.RowKeySet
      - - org.apache.myfaces.trinidad.model.RowKeySetImpl

- All Implemented Interfaces:
    Externalizable, Serializable, Cloneable, Iterable<Object>, Collection<Object>, Set<Object>

      public final class RowKeySetImpl
      extends RowKeySet
      implements 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

    Constructors
    Constructor and Description
    `RowKeySetImpl()` Creates an initially empty RowKeySet.
    `RowKeySetImpl(boolean addAll)` Creates a new RowKeySet.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Object rowKey)` Adds the current rowKey to this set.
    `void` | `addAll()` Adds every rowKey to this set.
    `boolean` | `addAll(Collection<? extends Object> c)`
    `void` | `clear()` Removes every rowKey from this set.
    `RowKeySetImpl` | `clone()` Creates a shallow clone of this RowKeySet.
    `boolean` | `contains(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(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()`
    `Iterator<Object>` | `iterator()` Gets an iteration of all the rowKeys contained in this Set.
    `void` | `readExternal(ObjectInput in)`
    `boolean` | `remove(Object rowKey)` Removes the current rowKey from this set.
    `boolean` | `removeAll(Collection<?> c)`
    `void` | `setCollectionModel(CollectionModel model)` Changes the underlying CollectionModel being used by this set.
    `int` | `size()`
    `void` | `writeExternal(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(Object rowKey)

      Checks to see the current rowKey is contained by 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 this set contains the current rowKey

    - #### add

          public boolean add(Object rowKey)

      Adds the current 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:
        true if this set changed

    - #### remove

          public boolean remove(Object rowKey)

      Removes the current 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:
        true if this set changed

    - #### invert

          public boolean invert(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 `Collection<Object>`
      Specified by:
        `clear` in interface `Set<Object>`
      Overrides:
        `clear` in class `AbstractCollection<Object>`

    - #### removeAll

          public boolean removeAll(Collection<?> c)

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

    - #### addAll

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

      Specified by:
        `addAll` in interface `Collection<Object>`
      Specified by:
        `addAll` in interface `Set<Object>`
      Overrides:
        `addAll` in class `AbstractCollection<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 `Collection<Object>`
      Specified by:
        `size` in interface `Set<Object>`
      Specified by:
        `size` in class `AbstractCollection<Object>`

    - #### isEmpty

          public boolean isEmpty()

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

    - #### iterator

          public Iterator<Object> iterator()

      Gets an iteration of all the rowKeys contained in this Set.
      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>`
      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(ObjectOutput out)
                             throws IOException

      Specified by:
        `writeExternal` in interface `Externalizable`
      Throws:
        `IOException`

    - #### readExternal

          public void readExternal(ObjectInput in)
                            throws IOException,
                                   ClassNotFoundException

      Specified by:
        `readExternal` in interface `Externalizable`
      Throws:
        `IOException`
        `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-2017 The Apache Software Foundation. All Rights Reserved.