Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle TopLink API Reference 10g Release 3 (10.1.3) B13698-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.toplink.indirection
Class IndirectSet

`java.lang.Object
oracle.toplink.indirection.IndirectSet`

All Implemented Interfaces:
  ChangeTracker, java.lang.Cloneable, java.util.Collection, CollectionChangeTracker, IndirectContainer, java.io.Serializable, java.util.Set

Direct Known Subclasses:
  EJBIndirectSet

public class IndirectSet
extends java.lang.Object
implements CollectionChangeTracker, java.util.Set, IndirectContainer, java.lang.Cloneable, java.io.Serializable

IndirectSet is an example implementation of the Set protocol that allows a domain class to take advantage of TopLink Indirection without having to declare its instance variable as a ValueHolderInterface.

To use an IndirectSet:

- Declare the appropriate instance variable with type Set (or Collection).
- Send the message #useTransparentCollection() to the appropriate CollectionMapping.
- Send the message #useCollectionClass(IndirectSet.class) to the same CollectionMapping. (The order of these two message sends is significant.)

TopLink will place an IndirectSet in the instance variable when the containing domain object is read from the datatabase. With the first message sent to the IndirectSet, the contents are fetched from the database and normal Set behavior is resumed.

Implementation notes:

- The Set interface is implemented by delegating nearly every message to the Set held on to by the 'delegate' instance variable. (The 'delegate' will be either a HashSet or yet another IndirectSet.)
- The IndirectContainer interface is implemented in a straightforward fashion:
  - #get- and #setValueHolder() are implemented as simple accessors for the 'valueHolder' instance variable. (Note that #setValueHolder() clears out the 'delegate' instance variable, since its contents are invalidated by the arrival of a new value holder.)
  - #isInstantiated() is simply delegated to the value holder.
- TopLink requires that the Cloneable interface be implemented. The #clone() method must clone the 'delegate'. (The implementation here uses reflection to invoke the #clone() method because it is not included in the common interface shared by IndirectSet and its base delegate class, HashSet; namely, Set.)
- TopLink requires that the Serializable interface be implemented.
- The database read is ultimately triggered when one of the "delegated" methods makes the first call to #getDelegate(), which in turn calls #buildDelegate(), which sends the message #getValue() to the value holder. The value holder performs the database read.
- For debugging purposes, #toString() will not trigger a database read. This is not required behavior.

Since:
  TOPLink/Java 3.0+
See Also:
  `CollectionMapping`, Serialized Form

Constructor Summary
`IndirectSet()` Construct an empty IndirectSet.
`IndirectSet(java.util.Collection c)` Construct an IndirectSet containing the elements of the specified collection.
`IndirectSet(int initialCapacity)` Construct an empty IndirectSet with the specified initial capacity.
`IndirectSet(int initialCapacity, float loadFactor)` Construct an empty IndirectSet with the specified initial capacity and load factor.

Method Summary
`boolean` | `add(java.lang.Object o)`
`boolean` | `addAll(java.util.Collection c)`
`void` | `clear()`
`java.lang.Object` | `clone()`
`boolean` | `contains(java.lang.Object o)`
`boolean` | `containsAll(java.util.Collection c)`
`boolean` | `equals(java.lang.Object o)`
`java.lang.String` | `getTopLinkAttributeName()` Return the mapping attribute name, used to raise change events.
`java.beans.PropertyChangeListener` | `getTopLinkPropertyChangeListener()` Return the property change listener for change tracking.
`ValueHolderInterface` | `getValueHolder()` Return the valueHolder.
`int` | `hashCode()`
`boolean` | `hasTopLinkPropertyChangeListener()` Return if the collection has a property change listener for change tracking.
`boolean` | `isEmpty()`
`boolean` | `isInstantiated()` Return whether the contents have been read from the database.
`java.util.Iterator` | `iterator()`
`boolean` | `remove(java.lang.Object o)`
`boolean` | `removeAll(java.util.Collection c)`
`boolean` | `retainAll(java.util.Collection c)`
`void` | `setTopLinkAttributeName(java.lang.String attributeName)` Set the mapping attribute name, used to raise change events.
`void` | `setTopLinkPropertyChangeListener(java.beans.PropertyChangeListener changeListener)` Set the property change listener for change tracking.
`void` | `setValueHolder(ValueHolderInterface valueHolder)` Set the value holder.
`int` | `size()`
`java.lang.Object[]` | `toArray()`
`java.lang.Object[]` | `toArray(java.lang.Object[] a)`
`java.lang.String` | `toString()` Use the delegate's #toString(); but wrap it with braces to indicate there is a bit of indirection.

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### IndirectSet

    public IndirectSet()

  Construct an empty IndirectSet.

### IndirectSet

    public IndirectSet(int initialCapacity)

  Construct an empty IndirectSet with the specified initial capacity.
Parameters:
  `initialCapacity` - the initial capacity of the set
Throws:
  `java.lang.IllegalArgumentException` - if the specified initial capacity is negative

### IndirectSet

    public IndirectSet(int initialCapacity,
                       float loadFactor)

  Construct an empty IndirectSet with the specified initial capacity and load factor.
Parameters:
  `initialCapacity` - the initial capacity of the set
  `loadFactor` - the load factor of the set
Throws:
  `java.lang.IllegalArgumentException` - if the specified initial capacity is negative

### IndirectSet

    public IndirectSet(java.util.Collection c)

  Construct an IndirectSet containing the elements of the specified collection.
Parameters:
  `c` - the initial elements of the set

Method Detail

### add

    public boolean add(java.lang.Object o)

  Specified by:
    `add` in interface `java.util.Set`
  See Also:
    `Set.add(java.lang.Object)`

### addAll

    public boolean addAll(java.util.Collection c)

  Specified by:
    `addAll` in interface `java.util.Set`
  See Also:
    `Set.addAll(java.util.Collection)`

### clear

    public void clear()

  Specified by:
    `clear` in interface `java.util.Set`
  See Also:
    `Set.clear()`

### clone

    public java.lang.Object clone()

  See Also:
    `This will result in a database query if necessary.`

### contains

    public boolean contains(java.lang.Object o)

  Specified by:
    `contains` in interface `java.util.Set`
  See Also:
    `Set.contains(java.lang.Object)`

### containsAll

    public boolean containsAll(java.util.Collection c)

  Specified by:
    `containsAll` in interface `java.util.Set`
  See Also:
    `Set.containsAll(java.util.Collection)`

### equals

    public boolean equals(java.lang.Object o)

  Specified by:
    `equals` in interface `java.util.Set`
  See Also:
    `Set.equals(java.lang.Object)`

### getValueHolder

    public ValueHolderInterface getValueHolder()

  Return the valueHolder.
  Specified by:
    `getValueHolder` in interface `IndirectContainer`
  Returns:
    oracle.toplink.indirection.ValueHolderInterface A representation of the valueholder * which this container uses

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in interface `java.util.Set`
  See Also:
    `Set.hashCode()`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `java.util.Set`
  See Also:
    `Set.isEmpty()`

### isInstantiated

    public boolean isInstantiated()

  Return whether the contents have been read from the database.
  Specified by:
    `isInstantiated` in interface `IndirectContainer`

### iterator

    public java.util.Iterator iterator()

  Specified by:
    `iterator` in interface `java.util.Set`
  See Also:
    `Set.iterator()`

### remove

    public boolean remove(java.lang.Object o)

  Specified by:
    `remove` in interface `java.util.Set`
  See Also:
    `Set.remove(java.lang.Object)`

### removeAll

    public boolean removeAll(java.util.Collection c)

  Specified by:
    `removeAll` in interface `java.util.Set`
  See Also:
    `Set.removeAll(java.util.Collection)`

### retainAll

    public boolean retainAll(java.util.Collection c)

  Specified by:
    `retainAll` in interface `java.util.Set`
  See Also:
    `Set.retainAll(java.util.Collection)`

### setValueHolder

    public void setValueHolder(ValueHolderInterface valueHolder)

  Set the value holder. Note that the delegate must be cleared out.
  Specified by:
    `setValueHolder` in interface `IndirectContainer`

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Set`
  See Also:
    `Set.size()`

### toArray

    public java.lang.Object[] toArray()

  Specified by:
    `toArray` in interface `java.util.Set`
  See Also:
    `Set.toArray()`

### toArray

    public java.lang.Object[] toArray(java.lang.Object[] a)

  Specified by:
    `toArray` in interface `java.util.Set`
  See Also:
    `Set.toArray(java.lang.Object[])`

### toString

    public java.lang.String toString()

  Use the delegate's #toString(); but wrap it with braces to indicate there is a bit of indirection. Don't allow this method to trigger a database read.
  See Also:
    `AbstractCollection.toString()`

### getTopLinkPropertyChangeListener

    public java.beans.PropertyChangeListener getTopLinkPropertyChangeListener()

  Return the property change listener for change tracking.
  Specified by:
    `getTopLinkPropertyChangeListener` in interface `ChangeTracker`

### hasTopLinkPropertyChangeListener

    public boolean hasTopLinkPropertyChangeListener()

  Return if the collection has a property change listener for change tracking.

### setTopLinkPropertyChangeListener

    public void setTopLinkPropertyChangeListener(java.beans.PropertyChangeListener changeListener)

  Set the property change listener for change tracking.
  Specified by:
    `setTopLinkPropertyChangeListener` in interface `ChangeTracker`

### getTopLinkAttributeName

    public java.lang.String getTopLinkAttributeName()

  Return the mapping attribute name, used to raise change events.
  Specified by:
    `getTopLinkAttributeName` in interface `CollectionChangeTracker`

### setTopLinkAttributeName

    public void setTopLinkAttributeName(java.lang.String attributeName)

  Set the mapping attribute name, used to raise change events. This is required if the change listener is set.
  Specified by:
    `setTopLinkAttributeName` in interface `CollectionChangeTracker`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 1998, 2006, Oracle. All Rights Reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD