org.apache.cocoon.components.source.impl
Class AbstractConfigurableSourceInspector

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.source.impl.AbstractConfigurableSourceInspector
All Implemented Interfaces:
Component, Configurable, LogEnabled, SourceInspector
Direct Known Subclasses:
AbstractConfigurableSourceDescriptor

public abstract class AbstractConfigurableSourceInspector
extends AbstractLogEnabled
implements SourceInspector, Configurable

Abstract base class for SourceInspectors that want to configure the set of properties they handle beforehand.

Knowing which properties an inspector handles beforehand greatly improves property management performance.

Author:
Unico Hommes

Field Summary
 
Fields inherited from interface org.apache.cocoon.components.source.SourceInspector
ROLE
 
Constructor Summary
AbstractConfigurableSourceInspector()
           
 
Method Summary
 void configure(Configuration configuration)
          Configure this source inspector to handle properties of required types.
protected abstract  SourceProperty doGetSourceProperty(Source source, String ns, String name)
          Do the actual work of getting the requested SourceProperty for the given Source.
protected  Set getPropertyTypes()
          Provide subclasses access to the set of configured properties.
 SourceProperty[] getSourceProperties(Source source)
          Iterates over the configured set of properties to handle, for each property calls doGetSourceProperty(), and returns the list of properties thus obtained.
 SourceProperty getSourceProperty(Source source, String namespace, String name)
          Checks if this inspector is configured to handle the requested property and if so forwards the call to doGetSourceProperty.
 boolean handlesProperty(String namespace, String name)
          Check if this inspector is configured to handle properties of the given type.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.components.source.SourceInspector
getValidity
 

Constructor Detail

AbstractConfigurableSourceInspector

public AbstractConfigurableSourceInspector()
Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Configure this source inspector to handle properties of required types.

Configuration is in the form of a set of property elements as follows:
<property name="owner" namespace="meta">

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

getSourceProperties

public SourceProperty[] getSourceProperties(Source source)
                                     throws SourceException
Iterates over the configured set of properties to handle, for each property calls doGetSourceProperty(), and returns the list of properties thus obtained. Subclasses may want to overide this behavior to improve performance.

Specified by:
getSourceProperties in interface SourceInspector
Parameters:
source - the Source for wich to compute the property.
Returns:
the collection of all SourceProperties that could be computed by this SourceInspector.
Throws:
SourceException

getSourceProperty

public final SourceProperty getSourceProperty(Source source,
                                              String namespace,
                                              String name)
                                       throws SourceException
Checks if this inspector is configured to handle the requested property and if so forwards the call to doGetSourceProperty.

Specified by:
getSourceProperty in interface SourceInspector
Parameters:
source - the source for which to compute the property
namespace - the namespace of the property
name - the name of the property
Returns:
the SourceProperty associated with the Source, null if the inspector does not provide this property.
Throws:
SourceException

doGetSourceProperty

protected abstract SourceProperty doGetSourceProperty(Source source,
                                                      String ns,
                                                      String name)
                                               throws SourceException
Do the actual work of getting the requested SourceProperty for the given Source.

Throws:
SourceException

handlesProperty

public final boolean handlesProperty(String namespace,
                                     String name)
Check if this inspector is configured to handle properties of the given type.

Specified by:
handlesProperty in interface SourceInspector
Parameters:
namespace - the namespace of the property
name - the name of the property
Returns:
true if this inspector handles properties of the given type else false.

getPropertyTypes

protected final Set getPropertyTypes()
Provide subclasses access to the set of configured properties.



Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.