|
Back to GWTP Home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectcom.gwtplatform.mvp.client.proxy.ParameterTokenFormatter
public class ParameterTokenFormatter
Formats tokens from 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, ParameterTokenFormatter 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, ParameterTokenFormatter 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) constructor.
| Field Summary | |
|---|---|
protected static String |
DEFAULT_HIERARCHY_SEPARATOR
|
protected static String |
DEFAULT_PARAM_SEPARATOR
|
protected static String |
DEFAULT_VALUE_SEPARATOR
|
protected static char |
ESCAPE_CHARACTER
|
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 Summary | |
|---|---|
ParameterTokenFormatter()
Builds a ParameterTokenFormatter using the default separators and escape character. |
|
ParameterTokenFormatter(String hierarchySeparator,
String paramSeparator,
String valueSeparator)
This constructor makes it possible to use custom separators in your token formatter. |
|
| 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 |
| Field Detail |
|---|
protected static final String DEFAULT_HIERARCHY_SEPARATOR
protected static final String DEFAULT_PARAM_SEPARATOR
protected static final String DEFAULT_VALUE_SEPARATOR
protected static final char 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
| Constructor Detail |
|---|
@Inject public ParameterTokenFormatter()
ParameterTokenFormatter using the default separators and escape character.
public ParameterTokenFormatter(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 %.| Method Detail |
|---|
public String toHistoryToken(List<PlaceRequest> placeRequestHierarchy)
throws TokenFormatException
TokenFormatterPlaceRequest) 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.
toHistoryToken in interface TokenFormatterplaceRequestHierarchy - The place request hierarchy.
TokenFormatException - if there is an error converting.
public PlaceRequest toPlaceRequest(String placeToken)
throws TokenFormatException
TokenFormatterPlaceRequest. A place token is different than a history
token, since the history token can contain a hierarchy of different place requests.
toPlaceRequest in interface TokenFormatterplaceToken - The place token.
TokenFormatException - if there is an error converting.
public List<PlaceRequest> toPlaceRequestHierarchy(String historyToken)
throws TokenFormatException
TokenFormatterPlaceRequest).
toPlaceRequestHierarchy in interface TokenFormatterhistoryToken - The history token.
TokenFormatException - if there is an error converting.
public String toPlaceToken(PlaceRequest placeRequest)
throws TokenFormatException
TokenFormatterPlaceRequest 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.
toPlaceToken in interface TokenFormatterplaceRequest - The place request.
TokenFormatException - if there is an error converting.
|
Back to GWTP Home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||