org.mmbase.framework.basic
Class BlockUrlConverter

java.lang.Object
  extended by org.mmbase.framework.basic.BlockUrlConverter
All Implemented Interfaces:
Serializable, UrlConverter
Direct Known Subclasses:
DirectoryUrlConverter

public abstract class BlockUrlConverter
extends Object
implements UrlConverter

A block url converter is an url converter which encodes in the URL precisely one block. Most URLConverters would probably be like this, and can extend from this.

Since:
MMBase-1.9
Version:
$Id: BlockUrlConverter.java 41989 2010-04-20 16:45:39Z michiel $
Author:
Michiel Meeuwissen
See Also:
Serialized Form
To Do:
EXPERIMENTAL

Field Summary
protected  Map<Component,Set<Block>> blocks
           
protected  Set<Component> components
           
protected  BasicFramework framework
           
 
Constructor Summary
BlockUrlConverter(BasicFramework fw)
           
 
Method Summary
protected  void addBlock(Block b)
          Explicitly add a block to make sure this BlockUrlConverter is only about that block.
protected  void addComponent(Component comp)
          Explicitly add a block to make sure this BlockUrlConverter is only about that block.
 Block getBlock(String path, Parameters frameworkParameters)
          Determins for which block an URL will be generated.
protected  Collection<Block> getBlocks(Component c)
          The blocks for which this UrlConverter can produce a 'nice' url.
protected  Collection<Component> getComponents()
          The components for which this UrlConverter can produce a 'nice' url.
 int getDefaultWeight()
           
protected  Block getExplicitBlock(String path, Parameters frameworkParameters)
          This proposal implemention simply uses Framework.COMPONENT and Framework.BLOCK framework parameters to determin the explicit block for getUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean, boolean), which may often be what you want.
protected abstract  Url getFilteredInternalUrl(String path, Map<String,?> params, Parameters frameworkParameters)
          When implementing this method you can assume that you don't have to return Url.NOT.
 Url getInternalUrl(String path, Map<String,?> params, Parameters frameworkParameters)
          See Framework.getInternalUrl(String, Map, Parameters).
protected abstract  Url getNiceUrl(Block block, Parameters blockParameters, Parameters frameworkParameters, boolean action)
          When implementing this method, you can already assume that the url must be 'nice', iow that we are actually rendering in the 'realm' of this UrlConverter, and you can straightforwardly, withough any checking, produce the URL.
 Parameter[] getParameterDefinition()
          Block url converters add an explicit 'component' and 'block' framework parameters
 Url getProcessUrl(String path, Map<String,?> parameters, Parameters frameworkParameters, boolean escapeAmps)
           
protected  State getState(Parameters frameworkParameters)
           
 Url getUrl(String path, Map<String,?> parameters, Parameters frameworkParameters, boolean escapeAmps)
          See Framework.getUrl(String, Map, Parameters, boolean).
protected  Url getUrl(String path, Map<String,?> parameters, Parameters frameworkParameters, boolean escapeAmps, boolean action)
          Parameterized proposal implementation for both getUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean, boolean) and getProcessUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean), because they will probably be about the same.
abstract  boolean isFilteredMode(Parameters frameworkParameters)
          Whether the current request already is in the realm of this URL-converter; the url converter must implement here how it recognizes itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

framework

protected final BasicFramework framework

components

protected Set<Component> components

blocks

protected final Map<Component,Set<Block>> blocks
Constructor Detail

BlockUrlConverter

public BlockUrlConverter(BasicFramework fw)
Method Detail

getParameterDefinition

public Parameter[] getParameterDefinition()
Block url converters add an explicit 'component' and 'block' framework parameters

Specified by:
getParameterDefinition in interface UrlConverter

addComponent

protected void addComponent(Component comp)
Explicitly add a block to make sure this BlockUrlConverter is only about that block.


addBlock

protected void addBlock(Block b)
Explicitly add a block to make sure this BlockUrlConverter is only about that block.


getComponents

protected Collection<Component> getComponents()
The components for which this UrlConverter can produce a 'nice' url. Or null if it can do that for any component.


getBlocks

protected Collection<Block> getBlocks(Component c)
The blocks for which this UrlConverter can produce a 'nice' url.


getExplicitBlock

protected Block getExplicitBlock(String path,
                                 Parameters frameworkParameters)
                          throws FrameworkException
This proposal implemention simply uses Framework.COMPONENT and Framework.BLOCK framework parameters to determin the explicit block for getUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean, boolean), which may often be what you want.

Throws:
FrameworkException

getBlock

public Block getBlock(String path,
                      Parameters frameworkParameters)
               throws FrameworkException
Determins for which block an URL will be generated. This is the explicit block, if that is defined. If it is not defined then it will use the currently rendered block and the 'path' to determin which one is meant now. That can be null if the current URL is not managed by this URLConverter.

Throws:
FrameworkException

getDefaultWeight

public int getDefaultWeight()
Specified by:
getDefaultWeight in interface UrlConverter

isFilteredMode

public abstract boolean isFilteredMode(Parameters frameworkParameters)
                                throws FrameworkException
Whether the current request already is in the realm of this URL-converter; the url converter must implement here how it recognizes itself.

Specified by:
isFilteredMode in interface UrlConverter
Throws:
FrameworkException

getState

protected State getState(Parameters frameworkParameters)

getUrl

protected final Url getUrl(String path,
                           Map<String,?> parameters,
                           Parameters frameworkParameters,
                           boolean escapeAmps,
                           boolean action)
                    throws FrameworkException
Parameterized proposal implementation for both getUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean, boolean) and getProcessUrl(java.lang.String, java.util.Map, org.mmbase.util.functions.Parameters, boolean), because they will probably be about the same.

Throws:
FrameworkException

getUrl

public Url getUrl(String path,
                  Map<String,?> parameters,
                  Parameters frameworkParameters,
                  boolean escapeAmps)
           throws FrameworkException
Description copied from interface: UrlConverter
See Framework.getUrl(String, Map, Parameters, boolean). But it can also return null which mean, 'I don't know.'

Specified by:
getUrl in interface UrlConverter
Parameters:
path - The path (generally a relative URL) to create an URL for.
parameters - Parameters The parameters to be passed to the page, as specified e.g. with mm:param -tags
frameworkParameters - The parameters that are required by the framework
escapeAmps - true if parameters should be added with an escaped & (&amp;). You should escape & when a URL is exposed (i.e. in HTML), but not if the url is for some reason called directly.
Returns:
An URL relative to the root of this web application (i.e. without a context path). Url.NOT if not determinable.
Throws:
FrameworkException - thrown when something goes wrong in the Framework

getProcessUrl

public Url getProcessUrl(String path,
                         Map<String,?> parameters,
                         Parameters frameworkParameters,
                         boolean escapeAmps)
                  throws FrameworkException
Specified by:
getProcessUrl in interface UrlConverter
Returns:
An URL relative to the root of this web application (i.e. without a context path). Never null
Throws:
FrameworkException

getNiceUrl

protected abstract Url getNiceUrl(Block block,
                                  Parameters blockParameters,
                                  Parameters frameworkParameters,
                                  boolean action)
                           throws FrameworkException
When implementing this method, you can already assume that the url must be 'nice', iow that we are actually rendering in the 'realm' of this UrlConverter, and you can straightforwardly, withough any checking, produce the URL.

Parameters:
block - Block for which the produce the url for
blockParameters - Parameters to use for this block. The implementation may set parameters to null which were represented in the returning String.
frameworkParameters -
action -
Throws:
FrameworkException

getInternalUrl

public final Url getInternalUrl(String path,
                                Map<String,?> params,
                                Parameters frameworkParameters)
                         throws FrameworkException
Description copied from interface: UrlConverter
See Framework.getInternalUrl(String, Map, Parameters).

Specified by:
getInternalUrl in interface UrlConverter
Parameters:
path - The page (e.g. image/css) provided by the component to create an URL for
params - Extra parameters for that path
frameworkParameters - The parameters that are required by the framework, such as the 'request' and 'cloud' objects
Returns:
A valid internal URL, or Url.NOT if nothing framework specific could be determined (this would make it possible to 'chain' frameworks).
Throws:
FrameworkException - thrown when something goes wrong in the Framework

getFilteredInternalUrl

protected abstract Url getFilteredInternalUrl(String path,
                                              Map<String,?> params,
                                              Parameters frameworkParameters)
                                       throws FrameworkException
When implementing this method you can assume that you don't have to return Url.NOT. IOW it is certain that the current URL is 'nice' according to this URL Converter.

Throws:
FrameworkException


MMBase 2.0-SNAPSHOT - null