Savarese.Org

org.savarese.unicorn.ui
Class AbstractObjectPanelModel<O>

java.lang.Object
  extended by org.savarese.unicorn.ui.AbstractObjectPanelModel<O>
All Implemented Interfaces:
ObjectPanelModel<O>
Direct Known Subclasses:
JavaBeanPanelModel, MBeanPanelModel, WebServicePanelModel

public abstract class AbstractObjectPanelModel<O>
extends java.lang.Object
implements ObjectPanelModel<O>

An abstract class implementing most of the methods declared by the ObjectPanelModel interface. It simplifies the implementation of the ObjectPanelModel interface.


Field Summary
protected  java.util.LinkedList<ObjectPanelModelListener<O>> _listeners_
          A list of ObjectPanelModelListener instances that are notified each time setObject(O) is called with a new object.
protected  O _object_
          The object wrapped by the model.
 
Constructor Summary
protected AbstractObjectPanelModel()
          Initializes _listeners_.
 
Method Summary
protected  void _notifyListeners_()
          Invokes ObjectPanelModelListener.modelChanged(org.savarese.unicorn.ui.ObjectPanelModel) for each ObjectPanelModelListener in _listeners_.
 void addObjectPanelModelListener(ObjectPanelModelListener<O> listener)
          Adds an ObjectPanelModelListener to the model.
 O getObject()
          Retrieves the object adapted to the interface.
 java.lang.String getObjectName()
          Returns a string that identifies the object.
 boolean isValid()
          Determines if the model is in a valid state.
 void removeObjectPanelModelListener(ObjectPanelModelListener<O> listener)
          Removes an ObjectPanelModelListener from the model.
 void setObject(O obj)
          Sets the object to be adapted to the interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.savarese.unicorn.ui.ObjectPanelModel
getAttribute, getObjectInfo, invoke, setAttribute
 

Field Detail

_object_

protected O _object_
The object wrapped by the model. It can be set and retrieved with setObject(O) and getObject().


_listeners_

protected java.util.LinkedList<ObjectPanelModelListener<O>> _listeners_
A list of ObjectPanelModelListener instances that are notified each time setObject(O) is called with a new object.

Constructor Detail

AbstractObjectPanelModel

protected AbstractObjectPanelModel()
Initializes _listeners_.

Method Detail

_notifyListeners_

protected void _notifyListeners_()
Invokes ObjectPanelModelListener.modelChanged(org.savarese.unicorn.ui.ObjectPanelModel) for each ObjectPanelModelListener in _listeners_.


setObject

public void setObject(O obj)
Description copied from interface: ObjectPanelModel
Sets the object to be adapted to the interface.

Specified by:
setObject in interface ObjectPanelModel<O>
Parameters:
obj - The object to be adapted.

getObject

public O getObject()
Description copied from interface: ObjectPanelModel
Retrieves the object adapted to the interface.

Specified by:
getObject in interface ObjectPanelModel<O>
Returns:
The object adapted to the interface.

getObjectName

public java.lang.String getObjectName()
Description copied from interface: ObjectPanelModel
Returns a string that identifies the object.

Specified by:
getObjectName in interface ObjectPanelModel<O>
Returns:
A string that identifies the object.

isValid

public boolean isValid()
Description copied from interface: ObjectPanelModel
Determines if the model is in a valid state. A model may be rendered invalid if it has no object, if an exception is occurs during a remote invocation operation, or any number of reasons specific to the model implementation.

Specified by:
isValid in interface ObjectPanelModel<O>
Returns:
True if the model is in a valid state, false if not.

addObjectPanelModelListener

public void addObjectPanelModelListener(ObjectPanelModelListener<O> listener)
Description copied from interface: ObjectPanelModel
Adds an ObjectPanelModelListener to the model. The listener is notifiied whenever the model changes.

Specified by:
addObjectPanelModelListener in interface ObjectPanelModel<O>
Parameters:
listener - The listener to add.

removeObjectPanelModelListener

public void removeObjectPanelModelListener(ObjectPanelModelListener<O> listener)
Description copied from interface: ObjectPanelModel
Removes an ObjectPanelModelListener from the model.

Specified by:
removeObjectPanelModelListener in interface ObjectPanelModel<O>
Parameters:
listener - The listener to remove.

Savarese.Org

Copyright © 2006 Daniel F. Savarese. All Rights Reserved.