Back to GWTP Home

com.gwtplatform.mvp.client.proxy
Class RouteTokenFormatter

Package class diagram package RouteTokenFormatter
java.lang.Object
  extended by com.gwtplatform.mvp.client.proxy.RouteTokenFormatter
All Implemented Interfaces:
TokenFormatter

public class RouteTokenFormatter
extends Object
implements TokenFormatter

Implementation of TokenFormatter with support for route like place names.

Instead of wiring a hierarchy of several places bound to multiple presenters this implements a flat structure where every history token is bound to a single presenter.

Usage:

Replace the default binding to ParameterTokenFormatter with RouteTokenFormatter. In case you use GWTPs DefaultModule:

 install(new DefaultModule(DefaultPlaceManager.class, RouteTokenFormatter.class));
 

Now all @NameToken's are treated as routes. Routes are expected to start with an '/' and can contain path parameters as well as query parameters.


Constructor Summary
RouteTokenFormatter(com.gwtplatform.mvp.client.proxy.RouteTokenFormatter.UrlUtils urlUtils, PlaceTokenRegistry tokenRegistry)
           
 
Method Summary
 String toHistoryToken(List<PlaceRequest> placeRequestHierarchy)
          Converts a place request hierarchy (a list of PlaceRequest) into a history token.
 PlaceRequest toPlaceRequest(String placeToken)
          Converts a place token into a PlaceRequest.
 List<PlaceRequest> toPlaceRequestHierarchy(String historyToken)
          Converts a history token into a place request hierarchy (a list of PlaceRequest).
 String toPlaceToken(PlaceRequest placeRequest)
          Converts a PlaceRequest into a place token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RouteTokenFormatter

@Inject
public RouteTokenFormatter(com.gwtplatform.mvp.client.proxy.RouteTokenFormatter.UrlUtils urlUtils,
                                  PlaceTokenRegistry tokenRegistry)
Method Detail

toPlaceToken

public String toPlaceToken(PlaceRequest placeRequest)
                    throws TokenFormatException
Description copied from interface: TokenFormatter
Converts a PlaceRequest into a place token. A place token is different than a history token, since the history token can contain a hierarchy of different place requests. The history token will not be fully query encoded, it may still contain some unescaped separators. However, these separators can be encoded and it will still work, making the scheme robust to systems that force encoding these characters like some email apps.

Specified by:
toPlaceToken in interface TokenFormatter
Parameters:
placeRequest - The place request.
Returns:
The place token, URL encoded.
Throws:
TokenFormatException - if there is an error converting.

toHistoryToken

public String toHistoryToken(List<PlaceRequest> placeRequestHierarchy)
                      throws TokenFormatException
Description copied from interface: TokenFormatter
Converts a place request hierarchy (a list of PlaceRequest) into a history token. The history token will not be fully query encoded, it may still contain some unescaped separators. However, these separators can be encoded and it will still work, making the scheme robust to systems that force encoding these characters like some email apps.

Specified by:
toHistoryToken in interface TokenFormatter
Parameters:
placeRequestHierarchy - The place request hierarchy.
Returns:
The history token, URL encoded.
Throws:
TokenFormatException - if there is an error converting.

toPlaceRequest

public PlaceRequest toPlaceRequest(String placeToken)
                            throws TokenFormatException
Description copied from interface: TokenFormatter
Converts a place token into a PlaceRequest. A place token is different than a history token, since the history token can contain a hierarchy of different place requests.

Specified by:
toPlaceRequest in interface TokenFormatter
Parameters:
placeToken - The place token.
Returns:
The place request.
Throws:
TokenFormatException - if there is an error converting.

toPlaceRequestHierarchy

public List<PlaceRequest> toPlaceRequestHierarchy(String historyToken)
                                           throws TokenFormatException
Description copied from interface: TokenFormatter
Converts a history token into a place request hierarchy (a list of PlaceRequest).

Specified by:
toPlaceRequestHierarchy in interface TokenFormatter
Parameters:
historyToken - The history token.
Returns:
The place request hierarchy.
Throws:
TokenFormatException - if there is an error converting.

Back to GWTP Home

Copyright © 2010-2013 ArcBees. All Rights Reserved.