org.beanfabrics
Class ModelProvider

java.lang.Object
  extended by org.beanfabrics.AbstractBean
      extended by org.beanfabrics.ModelProvider
All Implemented Interfaces:
java.io.Serializable, Bean, IModelProvider

public class ModelProvider
extends AbstractBean
implements IModelProvider, java.io.Serializable

The default implementation of a IModelProvider.

See Also:
Serialized Form

Constructor Summary
ModelProvider()
          Constructs an empty ModelProvider.
ModelProvider(java.lang.Class<? extends PresentationModel> presentationModelType)
          Constructs an empty ModelProvider for the given presentationModel type.
ModelProvider(PresentationModel presentationModel)
          Constructs a ModelProvider with the given presentationModel.
 
Method Summary
 void addModelProviderListener(Path path, ModelProviderListener l)
          Adds a ModelProviderListener to the listener list.
<T extends PresentationModel>
T
getPresentationModel()
          Returns the PM instance hold by this container.
<T extends PresentationModel>
T
getPresentationModel(Path path)
          Returns the PM found at the end of the specified path or null if nothing is found.
 java.lang.Class<? extends PresentationModel> getPresentationModelType()
          Returns the type of the PM, that is declared to be held at the root node of this provider.
 void removeModelProviderListener(Path path, ModelProviderListener l)
          Removes a ModelProviderListener from the listener list that was registered for a specific path.
 void setPresentationModel(PresentationModel newPresentationModel)
          Sets the given PM instance as root node into this provider.
 void setPresentationModelType(java.lang.Class<? extends PresentationModel> newType)
          Declares the type of the PM, that should be held at the root node of this provider.
 
Methods inherited from class org.beanfabrics.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, equals, getPropertyChangeSupport, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelProvider

public ModelProvider()
Constructs an empty ModelProvider.


ModelProvider

public ModelProvider(java.lang.Class<? extends PresentationModel> presentationModelType)
Constructs an empty ModelProvider for the given presentationModel type.


ModelProvider

public ModelProvider(PresentationModel presentationModel)
Constructs a ModelProvider with the given presentationModel.

Method Detail

getPresentationModel

public <T extends PresentationModel> T getPresentationModel()
Description copied from interface: IModelProvider
Returns the PM instance hold by this container. TODO: remove this unsafe type cast, or declare the type parameter at class level.

Specified by:
getPresentationModel in interface IModelProvider
Type Parameters:
T - the provided PM type
Returns:
the PM instance hold by this container

setPresentationModel

public void setPresentationModel(PresentationModel newPresentationModel)
Sets the given PM instance as root node into this provider.

Specified by:
setPresentationModel in interface IModelProvider
Parameters:
newPresentationModel - the PM

getPresentationModel

public <T extends PresentationModel> T getPresentationModel(Path path)
Returns the PM found at the end of the specified path or null if nothing is found.

Specified by:
getPresentationModel in interface IModelProvider
Type Parameters:
T - the provided PM type
Parameters:
path - the path to the target PM relative to the root node held by this provider
Returns:
the PM found at the end of the specified path or null if nothing was found

getPresentationModelType

public java.lang.Class<? extends PresentationModel> getPresentationModelType()
Returns the type of the PM, that is declared to be held at the root node of this provider. Never returns null.

Specified by:
getPresentationModelType in interface IModelProvider
Returns:
the type of the PM, that is declared to be held at the root node of this provider

setPresentationModelType

public void setPresentationModelType(java.lang.Class<? extends PresentationModel> newType)
Declares the type of the PM, that should be held at the root node of this provider.

Specified by:
setPresentationModelType in interface IModelProvider
Parameters:
newType - the type of the PM

addModelProviderListener

public void addModelProviderListener(Path path,
                                     ModelProviderListener l)
Adds a ModelProviderListener to the listener list. The listener is registered for all structural changes along the given path and will be informed whenever the model reference at the end of the path changes.

Specified by:
addModelProviderListener in interface IModelProvider
Parameters:
path - the path which references the presentation model
l - the listener to add

removeModelProviderListener

public void removeModelProviderListener(Path path,
                                        ModelProviderListener l)
Removes a ModelProviderListener from the listener list that was registered for a specific path.

Specified by:
removeModelProviderListener in interface IModelProvider
Parameters:
path - the path which references the presentation model
l - the listener to remove