org.apache.cocoon.components.treeprocessor.sitemap
Class SitemapLanguage

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.components.treeprocessor.DefaultTreeBuilder
          extended byorg.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage
All Implemented Interfaces:
Contextualizable, Disposable, LogEnabled, Poolable, Recyclable, Serviceable, TreeBuilder

public class SitemapLanguage
extends DefaultTreeBuilder

The tree builder for the sitemap language.

Version:
CVS $Id: SitemapLanguage.java 291716 2005-09-26 19:18:20Z cziegeler $
Author:
Sylvain Wallez

Nested Class Summary
 
Nested classes inherited from class org.apache.cocoon.components.treeprocessor.TreeBuilder
TreeBuilder.EventComponent
 
Field Summary
static String FIRST_POS_LABEL
          Pseudo-label for views from-position="first" (i.e. generator).
static String LAST_POS_LABEL
          Pseudo-label for views from-position="last" (i.e. serializer).
 
Fields inherited from class org.apache.cocoon.components.treeprocessor.DefaultTreeBuilder
applicationContainer, attributes, enterSitemapEventListeners, itsClassLoader, itsComponentInfo, itsNamespace, leaveSitemapEventListeners, parentProcessorManager, processor
 
Fields inherited from interface org.apache.cocoon.components.treeprocessor.TreeBuilder
ROLE
 
Constructor Summary
SitemapLanguage()
           
 
Method Summary
protected  void addListener(TreeBuilder.EventComponent listener)
          Add a listener
 void addViewForLabel(String label, String view)
          Add a view for a label.
protected  Context createContext(Configuration tree)
          Create a context that will be used for all Contextualizable ProcessingNodeBuilders and ProcessingNodes.
protected  TreeBuilder.EventComponent createListener(ServiceManager manager, Logger sitemapLogger, Context context, Configuration config)
          Create a listener
protected  ServiceManager createServiceManager(ClassLoader classloader, Context context, Configuration config)
          Build a component manager with the contents of the <map:components> element of the tree.
 Map getHintsForStatement(String role, String hint, Configuration statement)
          Extract pipeline-hints from the given statement (if any exist)
 String getMimeType(String role, String hint)
          Get the mime-type for a component (either a serializer or a reader)
 Map getViewNodes(Collection viewNames)
          Get the {view name, view node} map for a collection of view names.
 Collection getViewsForStatement(String role, String hint, Configuration statement)
          Get the names of views for a given statement.
 boolean isBuildingErrorHandler()
          Are we currently building an error handler ?
 boolean isBuildingView()
          Are we currently building a view ?
protected  void linkNodes()
          Before linking nodes, lookup the view category node used in getViewNodes(Collection).
 void recycle()
           
 void setBuildingErrorHandler(boolean building)
          Set to true while building the internals of a <map:handle-errors>
 void setBuildingView(boolean building)
          Set to true while building the internals of a <map:view>
 
Methods inherited from class org.apache.cocoon.components.treeprocessor.DefaultTreeBuilder
build, contextualize, createClassLoader, createNodeBuilder, createTree, dispose, getAttribute, getBuilderConfigURL, getBuiltProcessorClassLoader, getBuiltProcessorManager, getComponentLocator, getDisposableNodes, getEnterSitemapEventListeners, getLeaveSitemapEventListeners, getLocation, getNamespace, getParameters, getProcessor, getRegisteredNode, getTypeForStatement, registerNode, resolve, service, setAttribute, setParentProcessorManager, setProcessor, setupNode
 
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
 

Field Detail

FIRST_POS_LABEL

public static final String FIRST_POS_LABEL
Pseudo-label for views from-position="first" (i.e. generator).

See Also:
Constant Field Values

LAST_POS_LABEL

public static final String LAST_POS_LABEL
Pseudo-label for views from-position="last" (i.e. serializer).

See Also:
Constant Field Values
Constructor Detail

SitemapLanguage

public SitemapLanguage()
Method Detail

createServiceManager

protected ServiceManager createServiceManager(ClassLoader classloader,
                                              Context context,
                                              Configuration config)
                                       throws Exception
Build a component manager with the contents of the <map:components> element of the tree.

Overrides:
createServiceManager in class DefaultTreeBuilder
Returns:
a component manager
Throws:
Exception

createListener

protected TreeBuilder.EventComponent createListener(ServiceManager manager,
                                                    Logger sitemapLogger,
                                                    Context context,
                                                    Configuration config)
                                             throws Exception
Create a listener

Throws:
Exception

addListener

protected void addListener(TreeBuilder.EventComponent listener)
Add a listener


createContext

protected Context createContext(Configuration tree)
                         throws Exception
Description copied from class: DefaultTreeBuilder
Create a context that will be used for all Contextualizable ProcessingNodeBuilders and ProcessingNodes.

The default here is to simply return the context set in contextualize(), i.e. the context set by the calling TreeProcessor.

Subclasses can redefine this method to create a context local to a tree, such as for sitemap's <map:components>.

Overrides:
createContext in class DefaultTreeBuilder
Returns:
a context
Throws:
Exception
See Also:
DefaultTreeBuilder.createContext(org.apache.avalon.framework.configuration.Configuration)

recycle

public void recycle()
Specified by:
recycle in interface Recyclable
Overrides:
recycle in class DefaultTreeBuilder

setBuildingView

public void setBuildingView(boolean building)
Set to true while building the internals of a <map:view>


isBuildingView

public boolean isBuildingView()
Are we currently building a view ?


setBuildingErrorHandler

public void setBuildingErrorHandler(boolean building)
Set to true while building the internals of a <map:handle-errors>


isBuildingErrorHandler

public boolean isBuildingErrorHandler()
Are we currently building an error handler ?


addViewForLabel

public void addViewForLabel(String label,
                            String view)
Add a view for a label. This is used to register all views that start from a given label.

Parameters:
label - the label (or pseudo-label) for the view
view - the view name

getViewsForStatement

public Collection getViewsForStatement(String role,
                                       String hint,
                                       Configuration statement)
                                throws Exception
Get the names of views for a given statement. If the cocoon view exists in the returned collection, the statement can directly branch to the view-handling node.

Parameters:
role - the component role (e.g. Generator.ROLE)
hint - the component hint, i.e. the 'type' attribute
statement - the sitemap statement
Returns:
the view names for this statement
Throws:
Exception

linkNodes

protected void linkNodes()
                  throws Exception
Before linking nodes, lookup the view category node used in getViewNodes(Collection).

Overrides:
linkNodes in class DefaultTreeBuilder
Throws:
Exception

getViewNodes

public Map getViewNodes(Collection viewNames)
                 throws Exception
Get the {view name, view node} map for a collection of view names. This allows to resolve view nodes at build time, thus avoiding runtime lookup.

Parameters:
viewNames - the view names
Returns:
association of names to views
Throws:
Exception

getHintsForStatement

public Map getHintsForStatement(String role,
                                String hint,
                                Configuration statement)
                         throws Exception
Extract pipeline-hints from the given statement (if any exist)

Parameters:
role - the component role (e.g. Generator.ROLE)
hint - the component hint, i.e. the 'type' attribute
statement - the sitemap statement
Returns:
the hint params Map for this statement, or null if none exist
Throws:
Exception

getMimeType

public String getMimeType(String role,
                          String hint)
Get the mime-type for a component (either a serializer or a reader)

Parameters:
role - the component role (e.g. Serializer.ROLE)
hint - the component hint, i.e. the 'type' attribute
Returns:
the mime-type, or null if none was set


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.