org.nakedobjects.object.control
Class MutableAbout

java.lang.Object
  extended byorg.nakedobjects.object.control.MutableAbout
All Implemented Interfaces:
About, java.io.Serializable

public class MutableAbout
extends java.lang.Object
implements About

An implementation of the About interface whereby the Permission returned from canUse() and canAccess can change over time.

For simplicity, this about does not allow the use and access permissions to vary independently. In other words, if the Permission from one is a veto, then it will be from the other also.

Whenever the state of the about is changed (using the makeAvailable and makeUnavailable methods), any installed listeners are notified.

Implementation note: factory methods are provided to create these objects. See Joshua Bloch's Effective Java for further discussion.

See Also:
makeAvailable(), makeAvailable(String), makeUnavailable(String), AboutListener, TODO: Needs to be reviewed. The use of events within this class is potential problem. It must be remembered that the object that is suppose to be listening (if it is a naked object) might not actually be in memory., Serialized Form

Method Summary
 java.util.Enumeration aboutListeners()
          Returns enumeration of all registered listeners.
 void addAboutListener(AboutListener l)
          Registers an AboutListener.
 Permission canAccess()
          Whether the feature is "accessible" (presumably from the GUI) always returns the same as canUse().
 Permission canUse()
          Whether the feature is "usable", for example is editable.
static MutableAbout create()
          Factory method; creates an About (no name or description) whose permissions allow access and use.
static MutableAbout create(MutableAbout mutableAbout)
          Factory method; clones supplied MutableAbout.
static MutableAbout create(java.lang.String name, java.lang.String description)
          Factory method; creates an About whose permissions allow access and use.
protected  void fireAboutAvailable()
          Notifies all listeners that the about is now available.
protected  void fireAboutUnavailable()
          Notifies all listeners that the about is now unavailable.
 java.lang.String getDescription()
          Returns the description of the about.
 java.lang.String getName()
          Returns the name of the about.
 MutableAbout makeAvailable()
          Changes the permission (as returned by both canAccess() and canUse()) to be an Allow.
 MutableAbout makeAvailable(java.lang.String reason)
          Changes the permission (as returned by both canAccess() and canUse()) to be an Allow, with the specified reason.
 MutableAbout makeUnavailable(java.lang.String reason)
          Changes the permission (as returned by both canAccess() and canUse()) to be a Veto, with the specified reason.
 void removeAboutListener(AboutListener l)
          Removes an AboutListener from the collection of registered listeners.
 void setDescription(java.lang.String description)
          Sets the description of the about.
 void setName(java.lang.String name)
          Sets the description of the about.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static MutableAbout create()
Factory method; creates an About (no name or description) whose permissions allow access and use.

The makeUnavailable and makeAvailable methods can be used to subsequently change those permissions.

The name and description fields can also be subsequently set.

See Also:
makeUnavailable(String), makeAvailable(), makeAvailable(String), setName(String), setDescription(String)

create

public static MutableAbout create(java.lang.String name,
                                  java.lang.String description)
Factory method; creates an About whose permissions allow access and use.

See Also:
makeUnavailable(String), makeAvailable(), makeAvailable(String), About

create

public static MutableAbout create(MutableAbout mutableAbout)
Factory method; clones supplied MutableAbout. The name, description and permissions are all copied over.


aboutListeners

public final java.util.Enumeration aboutListeners()
Returns enumeration of all registered listeners.


addAboutListener

public final void addAboutListener(AboutListener l)
Registers an AboutListener. This will be notified if the about subsequently changes its state.


canAccess

public Permission canAccess()
Whether the feature is "accessible" (presumably from the GUI) always returns the same as canUse().

Specified by:
canAccess in interface About
See Also:
canUse()

canUse

public Permission canUse()
Whether the feature is "usable", for example is editable. The isAllowed() or isVetoed() methods should then be invoked to determine if the feature is usable.

Specified by:
canUse in interface About
See Also:
Permission.isAllowed(), Permission.isVetoed()

makeAvailable

public MutableAbout makeAvailable()
Changes the permission (as returned by both canAccess() and canUse()) to be an Allow. No reason is required (don't usually have to explain why something can be done, only why it can't.

See Also:
makeAvailable(String), makeUnavailable(String)

makeAvailable

public MutableAbout makeAvailable(java.lang.String reason)
Changes the permission (as returned by both canAccess() and canUse()) to be an Allow, with the specified reason.

See Also:
makeAvailable(), makeUnavailable(String), Allow

makeUnavailable

public MutableAbout makeUnavailable(java.lang.String reason)
Changes the permission (as returned by both canAccess() and canUse()) to be a Veto, with the specified reason.

See Also:
makeAvailable(), Veto

removeAboutListener

public final void removeAboutListener(AboutListener l)
Removes an AboutListener from the collection of registered listeners. This will no longer be notified if the about subsequently changes its state.


setDescription

public void setDescription(java.lang.String description)
Sets the description of the about. May be null.

See Also:
getDescription()

getDescription

public java.lang.String getDescription()
Returns the description of the about. May be null.

Specified by:
getDescription in interface About

setName

public void setName(java.lang.String name)
Sets the description of the about. May be null.

See Also:
getName()

getName

public java.lang.String getName()
Returns the name of the about. May be null.

Specified by:
getName in interface About

fireAboutAvailable

protected final void fireAboutAvailable()
Notifies all listeners that the about is now available. The event received by each listener will have the reason of the current permission. The permission itself is not propogated since it is not immutable and so would be susceptible to modification by listeners.

See Also:
fireAboutAvailable()

fireAboutUnavailable

protected final void fireAboutUnavailable()
Notifies all listeners that the about is now unavailable. The event received by each listener will have the reason of the current permission. The permission itself is not propogated since it is not immutable and so would be susceptible to modification by listeners.

See Also:
fireAboutAvailable()