org.apache.myfaces.trinidad.model

## Class RowKeySet

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

- All Implemented Interfaces:
    Cloneable, Iterable<Object>, Collection<Object>, Set<Object>
  Direct Known Subclasses:
    RowKeySetImpl, RowKeySetTreeImpl

      public abstract class RowKeySet
      extends AbstractSet<Object>
      implements Cloneable

  This Set is a mutable collection of rowKeys. This class is meant to be used with models that have a current rowKey concept. Therefore, the `add()`, `remove()` and `isContained()` methods do not need to take the rowKey as an argument, since the rowKey is implied. The implied key is obtained by calling `getCollectionModel()`.getRowKey()

  Because this Set has a reference to the underlying model, operations like `addAll()`, `removeAll()` and `invertAll()` may execute in constant time.

  Note that the `AbstractCollection.size()` method on the this Set might be expensive to compute. Use the `getSize()` method on this class for an inexpensive size.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RowKeySet()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add()` Adds the current key to this set.
    `abstract void` | `addAll()` Adds all the rowKeys in the current collection into this Set.
    `RowKeySet` | `clone()` Creates a shallow clone of this set.
    `protected abstract CollectionModel` | `getCollectionModel()` Gets the underlying model used by this set.
    `int` | `getSize()` Gets the number of elements contained by this set.
    `boolean` | `invert()` Adds the current rowKey to this set if it doesn't already exist; removes it otherwise.
    `boolean` | `invert(Object rowKey)` Adds the given rowKey to this set if it doesn't already exist, removes it otherwise.
    `abstract void` | `invertAll()` Inverts this Set.
    `boolean` | `isContained()` Checks to see if the current key is contained by this set.
    `abstract boolean` | `isContainedByDefault()` Deprecated. remove asap
    `boolean` | `remove()` Removes the current key from this set.
    `void` | `removeAll()` Removes all the rowKeys in the current collection from this Set.
    `abstract void` | `setCollectionModel(CollectionModel model)` Changes the underlying CollectionModel being used by this set.
    `void` | `setContained(boolean isContained)` Adds or removes the current key.

    - ### Methods inherited from class java.util.AbstractSet

      `equals, hashCode, removeAll`

    - ### Methods inherited from class java.util.AbstractCollection

      `add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, 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

      `add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toArray, toArray`

- - ### Constructor Detail

    - #### RowKeySet

          public RowKeySet()

  - ### Method Detail

    - #### isContainedByDefault

          @Deprecated
          public abstract boolean isContainedByDefault()

      Deprecated. remove asap

    - #### setCollectionModel

          public abstract 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.

    - #### getCollectionModel

          protected abstract CollectionModel getCollectionModel()

      Gets the underlying model used by this set.
      See Also:
        `setCollectionModel(org.apache.myfaces.trinidad.model.CollectionModel)`

    - #### invert

          public boolean invert(Object rowKey)

      Adds the given rowKey to this set if it doesn't already exist, removes it otherwise.
      Returns:
        true if the row is now added. false otherwise.

    - #### invert

          public final boolean invert()

      Adds the current rowKey to this set if it doesn't already exist; removes it otherwise.
      Returns:
        true if the row is now added. false otherwise.

    - #### isContained

          public final boolean isContained()

      Checks to see if the current key is contained by this set.
      Returns:
        true if this set contains the current key

    - #### setContained

          public final void setContained(boolean isContained)

      Adds or removes the current key.
      Parameters:
        `isContained` - if true, the current key is added to this set. if false, the current key is removed from this set.

    - #### add

          public final boolean add()

      Adds the current key to this set.
      Returns:
        true if this set changed. ie: true is returned if this set did not previously contain the current key.

    - #### remove

          public final boolean remove()

      Removes the current key from this set.
      Returns:
        true if this set changed. ie: true is returned if this set previously contained the current key.

    - #### getSize

          public int getSize()

      Gets the number of elements contained by this set. The difference between this method and `AbstractCollection.size()` is that this method may return -1 if the size is expensive to compute. This implementation simply calls `AbstractCollection.size()`.
      Returns:
        -1 if the number of elements is expensive to compute.

    - #### addAll

          public abstract void addAll()

      Adds all the rowKeys in the current collection into this Set. If the underlying model is a List, then all the rowKeys in the List are added to this Set. If the underlying model is a tree, then all the rowKeys in the current subtree are added to this Set.

    - #### removeAll

          public void removeAll()

      Removes all the rowKeys in the current collection from this Set. If the underlying model is a List, then all the rowKeys in the List are removed from this Set. If the underlying model is a tree, then all the rowKeys in the current subtree are removed from this Set.

      For List models, this method and `AbstractCollection.clear()` behave the same. For tree models, this method only operates on the current subtree, while the `AbstractCollection.clear()` method removes everything from this Set.

      This implementation simply calls `AbstractCollection.clear()`

    - #### invertAll

          public abstract void invertAll()

      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.

    - #### clone

          public RowKeySet clone()

      Creates a shallow clone of this set. Keys may be added or removed from the clone without affecting this instance. The keys themselves may not be cloned. This implementation simply calls `Object.clone()`
      Overrides:
        `clone` in class `Object`

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