gumbo.util
Class AbstractDelegatable

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.util.AbstractDelegatable
All Implemented Interfaces:
Delegatable, Disposable
Direct Known Subclasses:
AbstractDelegatable.Serial, AbstractDisplaySpace, AbstractViewSpace

public class AbstractDelegatable
extends AbstractDisposable
implements Delegatable

A full implementation of the Delegatable interface. Also implements Disposable, with a default implementation that nulls the delegator reference.

If extended by a serializable subclass, the subclass should throw an exception if it is disposed and serialization is attempted. The state of this object, which must be custom serialized, consists of the delegator (see AbstractDelegatable.Serial).

Version:
$Revision: 1.13 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Nested Class Summary
static class AbstractDelegatable.Serial
          Serializable version of AbstractDelegatable.
 
Constructor Summary
AbstractDelegatable()
          Creates an instance with an uninitialized delegator.
 
Method Summary
 java.lang.Object getDelegator()
          Gets the delegator of this delegate, as set by initDelegator().
protected  void implDispose()
          Nulls the delegator reference.
 Delegatable initDelegator(java.lang.Object delegator)
          Used by delegators and serialization to initialize this delegate's delegator reference.
protected  void initedDelegator()
          Called by initDelegator() after the delegator has been successfully initialized.
protected  void initingDelegator(java.lang.Object delegator)
          Called by initDelegator() to check this delegate's delegator.
 boolean isDelegatorInited()
          Also returns false if this object is disposed.
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDelegatable

public AbstractDelegatable()
Creates an instance with an uninitialized delegator. Must call initDelegator() before using this delegate, such as new AbstractDelegatable().initDelegator(d).

Method Detail

initingDelegator

protected void initingDelegator(java.lang.Object delegator)
Called by initDelegator() to check this delegate's delegator. Implementors can assume the delegator is non-null, should chain to the super method, and should throw an exception if the delegator is incompatible with this delegate. Default implementation: Does nothing (all delegators are compatible).

Parameters:
delegator - Reference to the delegator. Possibly this delegate but never null.

initedDelegator

protected void initedDelegator()
Called by initDelegator() after the delegator has been successfully initialized. Default implementation: Does nothing.


initDelegator

public final Delegatable initDelegator(java.lang.Object delegator)
Description copied from interface: Delegatable
Used by delegators and serialization to initialize this delegate's delegator reference. Re-initialization with the same value is allowed. Throws an exception if initialization fails for any reason.

Specified by:
initDelegator in interface Delegatable
Parameters:
delegator - Reference to the delegator. If self-delegation is allowed and the delegator is null, this object is the delegator (which facilitates inline construction).
Returns:
Reference to this delegatable (which facilitates inline construction).

isDelegatorInited

public final boolean isDelegatorInited()
Also returns false if this object is disposed.

Specified by:
isDelegatorInited in interface Delegatable
Returns:
The result.

getDelegator

public final java.lang.Object getDelegator()
Description copied from interface: Delegatable
Gets the delegator of this delegate, as set by initDelegator(). Throws an exception if isDelegatorInited() is false.

Specified by:
getDelegator in interface Delegatable
Returns:
Reference to the delegator. Possibly this delegate (self delegation) but never null.

implDispose

protected void implDispose()
Nulls the delegator reference. Does not dispose the delegator.

Specified by:
implDispose in class AbstractDisposable