no.sesat.search.view.navigation
Class BasicUrlGenerator

java.lang.Object
  extended by no.sesat.search.view.navigation.AbstractUrlGenerator
      extended by no.sesat.search.view.navigation.BasicUrlGenerator
All Implemented Interfaces:
UrlGenerator
Direct Known Subclasses:
NewsCaseUrlGenerator

public class BasicUrlGenerator
extends AbstractUrlGenerator

This implementation generates the URL components as parameters: param1=param1Value¶m1=param2value. It is designed for extension in a way that makes it easy to create a subclass that generates some of the url components as path components (e.g. /search/param1Value/?param2=param2value).

Since:
2.16
Version:
$Id: BasicUrlGenerator.java 6596 2008-05-10 10:05:48Z ssmiweve $

Constructor Summary
BasicUrlGenerator(DataModel dataModel, NavigationConfig.Navigation navigation, NavigationState state)
          Creates a new url generator.
 
Method Summary
protected  void appendParameterComponent(String component, String encodedValue)
          Appends the component and its encodedValue as a parameter component.
protected  void appendPathComponent(String component, String value)
          Appends the component as a path component.
protected  Set<String> getParameterComponents(NavigationConfig.Nav nav, Set<String> extraUrlComponents, String value)
          Returns the list of components which are supposded to be generated as parameter components.
protected  String getParameterValue(String parameter, String unencodedValue, NavigationConfig.Nav nav, Map<String,String> extraParameters)
           
protected  List<String> getPathComponents(NavigationConfig.Nav nav)
          Returns a list of components which are supposed to be generated as path components.
 String getURL(String unencodedValue, NavigationConfig.Nav nav)
          Returns the navigation URL for navigating nav to the given encodedValue.
 String getURL(String unencodedValue, NavigationConfig.Nav nav, Map<String,String> extraComponents)
          Returns the navigation URL for navigating nav to the given encodedValue.
protected  StringBuilder getUrlBuilder()
          Returns the string builder used for generating the url.
 
Methods inherited from class no.sesat.search.view.navigation.AbstractUrlGenerator
enc, getDataModel, getNavigationState, getPrefix, getUrlComponentNames, getUrlComponentValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicUrlGenerator

public BasicUrlGenerator(DataModel dataModel,
                         NavigationConfig.Navigation navigation,
                         NavigationState state)
Creates a new url generator.

Parameters:
dataModel - the datamodel.
navigation - the navigation to generate urls for.
state - the state of the current navigations.
Method Detail

getURL

public final String getURL(String unencodedValue,
                           NavigationConfig.Nav nav)
Returns the navigation URL for navigating nav to the given encodedValue. The navigation state is used to retrieve the state of all the other navigators on the page.

Parameters:
unencodedValue - the unencoded value.
nav - the navigator to navigate.
Returns:
the URL for the state.

getURL

public String getURL(String unencodedValue,
                     NavigationConfig.Nav nav,
                     Map<String,String> extraComponents)
Returns the navigation URL for navigating nav to the given encodedValue. The navigation state is used to retrieve the state of all the other navigators on the page.

Parameters:
unencodedValue - the unencoded value.
nav - the navigator to navigate.
extraComponents - any extra components that should go into the URL. these should be all unencoded.
Returns:
the URL for the state.

getPathComponents

protected List<String> getPathComponents(NavigationConfig.Nav nav)
Returns a list of components which are supposed to be generated as path components. This default implemementation returns the empty set (which means that all components are generated as parameter components by default) Override this method to get some of your navigators components generated as path components.

Parameters:
nav - the nav.
Returns:
List of path components.

getParameterComponents

protected Set<String> getParameterComponents(NavigationConfig.Nav nav,
                                             Set<String> extraUrlComponents,
                                             String value)
Returns the list of components which are supposded to be generated as parameter components. The default is the set of all components minus the list of path components.

Parameters:
nav - the nav.
extraUrlComponents - any extra components for the URL.
value -
Returns:
the set of parameter components.

appendPathComponent

protected void appendPathComponent(String component,
                                   String value)
Appends the component as a path component. This implementetion adds the encodedValue plus a slash. Value may be null or empty.

Parameters:
component - the component.
value - the value of the component.

appendParameterComponent

protected void appendParameterComponent(String component,
                                        String encodedValue)
Appends the component and its encodedValue as a parameter component. This implementetion adds component=encodedValue& if the encodedValue isn't empty.

Parameters:
component - the component.
encodedValue - the encodedValue of the component.

getParameterValue

protected String getParameterValue(String parameter,
                                   String unencodedValue,
                                   NavigationConfig.Nav nav,
                                   Map<String,String> extraParameters)
Parameters:
parameter - the parameter's name/key.
unencodedValue -
nav -
extraParameters -
Returns:
the value to use for the parameter. UTF-8 URL ENCODED.

getUrlBuilder

protected final StringBuilder getUrlBuilder()
Returns the string builder used for generating the url.

Returns:
the string builder.


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.