Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.scopemvc.core
Class PropertyManager  view PropertyManager download PropertyManager.java

java.lang.Object
  extended byorg.scopemvc.core.ModelManager
      extended byorg.scopemvc.core.PropertyManager

public abstract class PropertyManager
extends ModelManager

PropertyManager is a ModelManager that provides access to the properties of model objects. An implementation for JavaBean model objects is provided in org.scopemvc.model.beans.BeansPropertyManager.

Version:
$Revision: 1.4 $ $Date: 2002/01/12 09:35:40 $

Field Summary
private static java.lang.String NAME
           
 
Fields inherited from class org.scopemvc.core.ModelManager
modelClass
 
Constructor Summary
PropertyManager()
           
 
Method Summary
abstract  java.lang.Object get(java.lang.Object inModel, Selector inSelector)
           Return the value of the property identified by the passed Selector.
static PropertyManager getInstance(java.lang.Class inModelClass)
           
static PropertyManager getInstance(java.lang.Object inModel)
           
abstract  java.lang.Class getPropertyClass(java.lang.Object inModel, Selector inSelector)
          Return the Class of a property.
abstract  Selector getSelectorFor(java.lang.Object inModel, java.lang.Object inProperty)
          Return a Selector that would get() a property equals() to the passed Object.
abstract  java.util.Iterator getSelectorIterator(java.lang.Object inModel)
           Return an Iterator that iterates over Selectors for all properties of the passed model object.
abstract  boolean hasProperty(java.lang.Object inModel, Selector inSelector)
          Does the passed model object contain the property identified by the passed Selector?
abstract  boolean isReadOnly(java.lang.Object inModel, Selector inSelector)
           Is a property read-only? If the passed Selector is null then is the model object as a whole read-only?
abstract  void set(java.lang.Object inModel, Selector inSelector, java.lang.Object inValue)
           Set the value of the property identified by a Selector in the passed model object to a new value.
 
Methods inherited from class org.scopemvc.core.ModelManager
make
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values
Constructor Detail

PropertyManager

public PropertyManager()
Method Detail

getInstance

public static PropertyManager getInstance(java.lang.Class inModelClass)

getInstance

public static PropertyManager getInstance(java.lang.Object inModel)

get

public abstract java.lang.Object get(java.lang.Object inModel,
                                     Selector inSelector)
                              throws java.lang.Exception

Return the value of the property identified by the passed Selector. If the passed Selector is null, return the model object itself.


set

public abstract void set(java.lang.Object inModel,
                         Selector inSelector,
                         java.lang.Object inValue)
                  throws java.lang.Exception

Set the value of the property identified by a Selector in the passed model object to a new value.

The implementation should not set the value if the new value has the same Object reference as the original. It could also avoid setting the value if the new value is equivalent to the old value, and the value is of an immutable Class (like Integer, String). Otherwise the property must be set to the new value, even if it equals() the old value.

Usually, a ModelChangeEvent for ModelChangeTypes.VALUE_CHANGED 55 should be broadcast by the model when the property is set so that interested listeners know that the model's state has changed.

If the property is a sub-model object then the parent model should be registered as a ModelChangeListener to be able to propogate events properly. This propogation is partially implemented in org.scopemvc.model.basic.BasicModel but it relies on child Models being listened to by their parent. (Note: deregister from the old Model then register with the new one). See the sample code for examples using org.scopemvc.model.basic.BasicModel#listenNewSubmodel and org.scopemvc.model.basic.BasicModel#unlistenOldSubmodel.


isReadOnly

public abstract boolean isReadOnly(java.lang.Object inModel,
                                   Selector inSelector)
                            throws java.lang.Exception

Is a property read-only? If the passed Selector is null then is the model object as a whole read-only?

Enforcement of the access state must be implemented by the model itself.


hasProperty

public abstract boolean hasProperty(java.lang.Object inModel,
                                    Selector inSelector)
Does the passed model object contain the property identified by the passed Selector?


getPropertyClass

public abstract java.lang.Class getPropertyClass(java.lang.Object inModel,
                                                 Selector inSelector)
                                          throws java.lang.Exception
Return the Class of a property.


getSelectorIterator

public abstract java.util.Iterator getSelectorIterator(java.lang.Object inModel)

Return an Iterator that iterates over Selectors for all properties of the passed model object.


getSelectorFor

public abstract Selector getSelectorFor(java.lang.Object inModel,
                                        java.lang.Object inProperty)
Return a Selector that would get() a property equals() to the passed Object. Guaranteed to work only for non-primitive properties.