com.inline.feature.common
Class AbstractFeatureModel

java.lang.Object
  |
  +--com.inline.feature.common.AbstractFeatureModel
Direct Known Subclasses:
JavaFeatureModel

public abstract class AbstractFeatureModel
extends java.lang.Object
implements FeatureModel

Recommended superclass for FeatureModels. In cooperation with FeatureService, this class uses all kinds of factories (FeatureFactories, FeatureActionFactories, FeatureConstructorFactories, FeatureConfigurationFactories, DisplayPropertyFactories) to manage a self-assembling hierarchy of Features.


Fields inherited from interface com.inline.feature.FeatureModel
DISPLAY_MODE, STANDARD_DISPLAY_MODE, TYPE
 
Constructor Summary
AbstractFeatureModel(com.inline.resources.ResourceRepository repository)
           
 
Method Summary
protected  void addFeatureActionFactory(FeatureActionFactory factory, java.lang.String featureType)
          Called during model initialization for each available FeatureActionFactory that will supply FeatureActions for the features of the specified feature type.
protected  void addFeatureConstructorFactory(FeatureConstructorFactory factory, java.lang.String parentType, java.lang.String childType)
          Called during model initialization for each available FeatureConstructorFactory that will supply feature constructors of the specified child type for the features of the specified parent type.
protected  void addFeatureFactory(FeatureFactory factory, java.lang.String parentType, java.lang.String childType)
          Called during model initialization for each available feature factory that will supply feature sets of the specified child type for the features of the specified parent type.
protected  void appendVerboseDescription(java.lang.StringBuffer buffer, Feature feature, int indent)
           
 void commit()
          Saves changes made to the model in the persistent resources.
 void featureChanged(Feature feature, java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
          Called by all features when they are modified.
 void featureDeleted(Feature feature)
          Called by all features when they are deleted.
 void featureInserted(Feature feature)
          Called by all FeatureSets when they are inserted into the model.
 com.sun.java.util.collections.Set getAdditionalActions(Feature parent)
          Returns a set of FeatureActions provided by FeatureActionFactories for the supplied feature.
 com.sun.java.util.collections.Set getAdditionalFeatureConstructors(Feature parent, java.lang.String childType)
          Returns a set of FeatureConstructors for the supplied parent and child type.
 FeatureSet getChildFeatureSet(Feature parent)
          Allocates and configures an AggregateFeatureSet composed of individual FeatureSets produced by all participating FeatureFactories.
protected  DisplayPropertyFactory getDefaultDisplayPropertyFactory()
          Override to provide a default display property factory.
 DisplayProperties getDisplayProperties(Displayable object)
          Invokes getDisplayProperties(object) on the appropriate DisplayPropertyFactory.
protected  FeatureService getFeatureService()
           
 ResourceAdapter getResourceAdapter(com.inline.resources.ResourceReference reference)
          Resource adaptor will do a lot of resource management: create resources, post events when the resources change, maintain timestamps etc.
 com.inline.resources.ResourceRepository getResourceRepository()
          Returns the resource repository this FeatureModel is associated with.
 ResourceSetAdapter getResourceSetAdapter(java.lang.String type, com.inline.resources.ResourceQualifier qualifier)
          Will post events when a resource of the corresponding type satisfying the qualifier is created/removed.
 boolean isDefaultFeatureConstructor(Feature parent, java.lang.String childType, FeatureConstructor constructor)
          The model can select the default feature constructor.
 boolean isFeatureActionEnabled(Feature feature, FeatureAction action)
          The model can veto child allocation by a factory.
 boolean isFeatureActionFactoryEnabled(Feature feature, FeatureActionFactory factory)
          The model can veto feature action allocation by a factory.
 boolean isFeatureConstructorEnabled(Feature parent, java.lang.String childType, FeatureConstructor constructor)
          The model can disable a FeatureConstructor.
 boolean isFeatureConstructorFactoryEnabled(Feature parent, java.lang.String childType, FeatureConstructorFactory factory)
          The model can veto feature constructor allocation by a factory.
 boolean isFeatureFactoryEnabled(Feature parent, java.lang.String type, FeatureFactory factory)
          The model can veto child recognition by a factory
 boolean isFeatureRecognitionEnabled(Feature parent, java.net.URL url, FeatureFactory factory)
          The model can veto child allocation by a factory.
 void reparse()
          Initiates the resource parsing process.
 void resourceModified(ResourceAdapter adapter)
          Called by all feature during the commit process.
 java.lang.String toString()
           
 java.lang.String toStringVerbose()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractFeatureModel

public AbstractFeatureModel(com.inline.resources.ResourceRepository repository)
Method Detail

getFeatureService

protected FeatureService getFeatureService()

getResourceRepository

public com.inline.resources.ResourceRepository getResourceRepository()
Returns the resource repository this FeatureModel is associated with.
Specified by:
getResourceRepository in interface FeatureModel

getChildFeatureSet

public FeatureSet getChildFeatureSet(Feature parent)
Allocates and configures an AggregateFeatureSet composed of individual FeatureSets produced by all participating FeatureFactories.
Specified by:
getChildFeatureSet in interface FeatureModel
See Also:
AggregateFeatureSet, FeatureFactory, FeatureService.getFeatureFactories()

addFeatureFactory

protected void addFeatureFactory(FeatureFactory factory,
                                 java.lang.String parentType,
                                 java.lang.String childType)
Called during model initialization for each available feature factory that will supply feature sets of the specified child type for the features of the specified parent type.

getDisplayProperties

public DisplayProperties getDisplayProperties(Displayable object)
Invokes getDisplayProperties(object) on the appropriate DisplayPropertyFactory.
Specified by:
getDisplayProperties in interface FeatureModel
See Also:
DisplayPropertyFactory

getDefaultDisplayPropertyFactory

protected DisplayPropertyFactory getDefaultDisplayPropertyFactory()
Override to provide a default display property factory. That factory will be used when all other factories fail to provide DisplayProperties for a Displayable object.

The default implementation returns null.


getAdditionalFeatureConstructors

public com.sun.java.util.collections.Set getAdditionalFeatureConstructors(Feature parent,
                                                                          java.lang.String childType)
Description copied from interface: FeatureModel
Returns a set of FeatureConstructors for the supplied parent and child type. The list only includes additional FeatureConstructors provided by FeatureConstructorFactories, not the primitive ones created directly by FeatureSets. Do not call this method directly, call FeatureSet.getFeatureConstructors(type) instead.
Specified by:
getAdditionalFeatureConstructors in interface FeatureModel
Tags copied from interface: FeatureModel
See Also:
FeatureConstructor, FeatureConstructorFactory, AbstractFeatureSet.getFeatureConstructors(String)

addFeatureConstructorFactory

protected void addFeatureConstructorFactory(FeatureConstructorFactory factory,
                                            java.lang.String parentType,
                                            java.lang.String childType)
Called during model initialization for each available FeatureConstructorFactory that will supply feature constructors of the specified child type for the features of the specified parent type.

getAdditionalActions

public com.sun.java.util.collections.Set getAdditionalActions(Feature parent)
Description copied from interface: FeatureModel
Returns a set of FeatureActions provided by FeatureActionFactories for the supplied feature. It does not include the primitive actions produced by features themselves and their child feature sets. Do not call this method directly, call Feature.getActions() instead.
Specified by:
getAdditionalActions in interface FeatureModel
Tags copied from interface: FeatureModel
See Also:
FeatureAction, FeatureActionFactory, AbstractFeature.getActions()

addFeatureActionFactory

protected void addFeatureActionFactory(FeatureActionFactory factory,
                                       java.lang.String featureType)
Called during model initialization for each available FeatureActionFactory that will supply FeatureActions for the features of the specified feature type.

isFeatureFactoryEnabled

public boolean isFeatureFactoryEnabled(Feature parent,
                                       java.lang.String type,
                                       FeatureFactory factory)
The model can veto child recognition by a factory
Specified by:
isFeatureFactoryEnabled in interface FeatureModel

isFeatureRecognitionEnabled

public boolean isFeatureRecognitionEnabled(Feature parent,
                                           java.net.URL url,
                                           FeatureFactory factory)
The model can veto child allocation by a factory. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isFeatureRecognitionEnabled in interface FeatureModel

isFeatureActionFactoryEnabled

public boolean isFeatureActionFactoryEnabled(Feature feature,
                                             FeatureActionFactory factory)
The model can veto feature action allocation by a factory. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isFeatureActionFactoryEnabled in interface FeatureModel

isFeatureActionEnabled

public boolean isFeatureActionEnabled(Feature feature,
                                      FeatureAction action)
The model can veto child allocation by a factory. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isFeatureActionEnabled in interface FeatureModel

isFeatureConstructorFactoryEnabled

public boolean isFeatureConstructorFactoryEnabled(Feature parent,
                                                  java.lang.String childType,
                                                  FeatureConstructorFactory factory)
The model can veto feature constructor allocation by a factory. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isFeatureConstructorFactoryEnabled in interface FeatureModel

isFeatureConstructorEnabled

public boolean isFeatureConstructorEnabled(Feature parent,
                                           java.lang.String childType,
                                           FeatureConstructor constructor)
The model can disable a FeatureConstructor. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isFeatureConstructorEnabled in interface FeatureModel

isDefaultFeatureConstructor

public boolean isDefaultFeatureConstructor(Feature parent,
                                           java.lang.String childType,
                                           FeatureConstructor constructor)
The model can select the default feature constructor. The actual answer is provided by relevant FeatureModelConfigurators.
Specified by:
isDefaultFeatureConstructor in interface FeatureModel

getResourceAdapter

public ResourceAdapter getResourceAdapter(com.inline.resources.ResourceReference reference)
Resource adaptor will do a lot of resource management: create resources, post events when the resources change, maintain timestamps etc.
Specified by:
getResourceAdapter in interface FeatureModel

getResourceSetAdapter

public ResourceSetAdapter getResourceSetAdapter(java.lang.String type,
                                                com.inline.resources.ResourceQualifier qualifier)
Will post events when a resource of the corresponding type satisfying the qualifier is created/removed.
Specified by:
getResourceSetAdapter in interface FeatureModel

reparse

public void reparse()
Initiates the resource parsing process. The default implementation invokes reparse() on all registered ResourceAdapters and ResourceSetAdapters. Those adapters can then post resourceChange events to their listeners, which may initiate the resource parsing by those listeners.
Specified by:
reparse in interface FeatureModel

commit

public void commit()
            throws InvalidFeatureException
Saves changes made to the model in the persistent resources. The default implementation first invokes Feature.commit() on all modified features. That method will call resourceModified() on the model. The second phase of the commit process is to call commit(SHALLOW_COMMIT) on all modified resources. Finally, commit invokes reparse() on itself.
Specified by:
commit in interface FeatureModel

featureChanged

public void featureChanged(Feature feature,
                           java.lang.String property,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Called by all features when they are modified. If the feature inherits from AbstractFeature, the call is made by AbstractFeature.firePropertyChange()
Specified by:
featureChanged in interface FeatureModel

featureInserted

public void featureInserted(Feature feature)
Called by all FeatureSets when they are inserted into the model. If the FeatureSet inherits from AbstractTypedFeatureSet, the call is made by AbstractTypedFeatureSet.insert()
Specified by:
featureInserted in interface FeatureModel

featureDeleted

public void featureDeleted(Feature feature)
Called by all features when they are deleted. If the feature inherits from AbstractFeature, the call is made by AbstractFeature.markForDeletion()
Specified by:
featureDeleted in interface FeatureModel

resourceModified

public void resourceModified(ResourceAdapter adapter)
Called by all feature during the commit process. If the feature inherits from AbstractFeature, the call is made by AbstractFeature.commit()
Specified by:
resourceModified in interface FeatureModel

toStringVerbose

public java.lang.String toStringVerbose()

appendVerboseDescription

protected void appendVerboseDescription(java.lang.StringBuffer buffer,
                                        Feature feature,
                                        int indent)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object