public class NewTokenFormatter extends Object implements com.gwtplatform.mvp.shared.proxy.TokenFormatter
String values to PlaceRequest and PlaceRequest hierarchies and vice-versa. The default implementation
uses:
'/' to separate PlaceRequests in a hierarchy;';' to separate parameters in a PlaceRequest;'=' to separate the parameter name from its value;'\' to escape separators inside parameters names and values in a PlaceRequest.'\' character by replacing '/' with '\0', ';' with '\1', '=' with '\2' and '\' with
'\3'.
Before decoding a String URL fragment into a PlaceRequest or a PlaceRequest hierarchy, NewTokenFormatter will first
pass the String through URL.decodeQueryString(String) so that if the URL was URL-encoded by some user agent, like a mail user
agent, it is still parsed correctly.
For example, NewTokenFormatter would parse any of the following:
nameToken1%3Bparam1.1%3Dvalue1.1%3Bparam1.2%3Dvalue1.2%2FnameToken2%2FnameToken3%3Bparam3.1%3Dvalue%03%11 nameToken1;param1.1=value1.1;param1.2=value1.2/nameToken2/nameToken3;param3.1=value\03\21Into the following hierarchy of
PlaceRequest:
{
{ "nameToken1", { {"param1.1", "value1.1"}, {"parame1.2","value1.2"} },
"nameToken2", {},
"nameToken3", { {"param3.1", "value/3=1"} } }
}
If you want to use different symbols as separator, use the #ParameterTokenFormatter(String, String, String, String) constructor.| Modifier and Type | Field and Description |
|---|---|
protected static String |
DEFAULT_ESCAPE_CHARACTER |
protected static String |
DEFAULT_HIERARCHY_SEPARATOR |
protected static String |
DEFAULT_PARAM_SEPARATOR |
protected static String |
DEFAULT_VALUE_SEPARATOR |
protected static String |
ESCAPED_ESCAPE_CHAR |
protected static String |
ESCAPED_HIERARCHY_SEPARATOR |
protected static String |
ESCAPED_PARAM_SEPARATOR |
protected static String |
ESCAPED_VALUE_SEPARATOR |
| Constructor and Description |
|---|
NewTokenFormatter()
Builds a
NewTokenFormatter using the default separators and escape character. |
NewTokenFormatter(String hierarchySeparator,
String paramSeparator,
String valueSeparator)
This constructor makes it possible to use custom separators in your token formatter.
|
NewTokenFormatter(String hierarchySeparator,
String paramSeparator,
String valueSeparator,
String escapeCharacter)
This constructor makes it possible to use custom separators and custom escape character in your token formatter.
|
| Modifier and Type | Method and Description |
|---|---|
String |
toHistoryToken(List<com.gwtplatform.mvp.shared.proxy.PlaceRequest> placeRequestHierarchy) |
com.gwtplatform.mvp.shared.proxy.PlaceRequest |
toPlaceRequest(String placeToken) |
List<com.gwtplatform.mvp.shared.proxy.PlaceRequest> |
toPlaceRequestHierarchy(String historyToken) |
String |
toPlaceToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest placeRequest) |
protected static final String DEFAULT_HIERARCHY_SEPARATOR
protected static final String DEFAULT_PARAM_SEPARATOR
protected static final String DEFAULT_VALUE_SEPARATOR
protected static final String DEFAULT_ESCAPE_CHARACTER
protected static final String ESCAPED_HIERARCHY_SEPARATOR
protected static final String ESCAPED_PARAM_SEPARATOR
protected static final String ESCAPED_VALUE_SEPARATOR
protected static final String ESCAPED_ESCAPE_CHAR
@Inject public NewTokenFormatter()
NewTokenFormatter using the default separators and escape character.public NewTokenFormatter(String hierarchySeparator, String paramSeparator, String valueSeparator)
URL.encodeQueryString(String))hierarchySeparator - The symbol used to separate PlaceRequest in a hierarchy. Must be a 1-character string and can't be %.paramSeparator - The symbol used to separate parameters in a PlaceRequest. Must be a 1-character string and can't be %.valueSeparator - The symbol used to separate the parameter name from its value. Must be a 1-character string and can't be %.public NewTokenFormatter(String hierarchySeparator, String paramSeparator, String valueSeparator, String escapeCharacter)
URL.encodeQueryString(String))hierarchySeparator - The symbol used to separate PlaceRequest in a hierarchy. Must be a 1-character string and can't be %.paramSeparator - The symbol used to separate parameters in a PlaceRequest. Must be a 1-character string and can't be %.valueSeparator - The symbol used to separate the parameter name from its value. Must be a 1-character string and can't be %.escapeCharacter - The symbol used to escape the separator symbols inside parameter names and values. Must be a 1-character string and can't be
%.public String toHistoryToken(List<com.gwtplatform.mvp.shared.proxy.PlaceRequest> placeRequestHierarchy) throws com.gwtplatform.mvp.shared.proxy.TokenFormatException
toHistoryToken in interface com.gwtplatform.mvp.shared.proxy.TokenFormattercom.gwtplatform.mvp.shared.proxy.TokenFormatExceptionpublic com.gwtplatform.mvp.shared.proxy.PlaceRequest toPlaceRequest(String placeToken) throws com.gwtplatform.mvp.shared.proxy.TokenFormatException
toPlaceRequest in interface com.gwtplatform.mvp.shared.proxy.TokenFormattercom.gwtplatform.mvp.shared.proxy.TokenFormatExceptionpublic List<com.gwtplatform.mvp.shared.proxy.PlaceRequest> toPlaceRequestHierarchy(String historyToken) throws com.gwtplatform.mvp.shared.proxy.TokenFormatException
toPlaceRequestHierarchy in interface com.gwtplatform.mvp.shared.proxy.TokenFormattercom.gwtplatform.mvp.shared.proxy.TokenFormatExceptionpublic String toPlaceToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest placeRequest) throws com.gwtplatform.mvp.shared.proxy.TokenFormatException
toPlaceToken in interface com.gwtplatform.mvp.shared.proxy.TokenFormattercom.gwtplatform.mvp.shared.proxy.TokenFormatExceptionCopyright © 2014 JBoss, a division of Red Hat. All rights reserved.