| java.lang.Object | |
| ↳ | com.google.gdata.util.httputil.FastURLEncoder |
This class has been deprecated; use uriEscaper(),
cppUriEscaper() or create your
own custom PercentEscaper.
Almost every use of FastURLEncoder can now be replaced with an instance of the PercentEscaper class, which is much faster.
In most cases it should be possible to use the static instances available
from CharEscapers but it is also possible to
create your own escaper with custom behaviour.
See Deprecating FastURLEncoder for more information.
Note that the new uriEscaper only escapes using UTF-8 encoding and while no examples of other encodings were found when preparing this class for deprecation, it's possible that some instance were missed. If you have a valid reason to escape URIs via an encoding other than UTF-8 please let the java-libraries-team know.
FastURLEncoder is intended as a replacement for the slow and inefficient java.net.URLEncoder. There are a few differences though:
It is possible that URLEncoder is doing really complicated stuff for a reason and that I just don't understand why. If you are unsure of FastURLEncoder just call FastURLEncoder.setVerifyAgainstJava(true). This will run both versions and verify that the outputs are the same. Of course this will be slow but it is useful for testing. I wouldn't be surprised if the two differ for non-latin1, non-utf-8 encodings.
FastURLEncoder requires jdk 1.5.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| CPLUSPLUS_COMPAT_SAFE_OCTETS |
This field is deprecated.
Use cppUriEscaper()
|
||||||||||
| DEFAULT_SAFE_OCTETS | These octets all go directly into the URL, all others are escaped. | ||||||||||
| HEX_DIGITS | java.net.URLEncoder uses upper-case hex digits so we should too. | ||||||||||
| verifyAgainstJava | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
Use
uriEscaper().
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper()
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper().
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper()
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper().
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper().
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper().
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
| |||||||||||
This method is deprecated.
Use
uriEscaper().
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
This field is deprecated.
Use cppUriEscaper()
These octets mimic the ones escaped by the C++ webutil/url URL class -- the kGoogle1Escape set. To produce the same escaping as C++, use this BitSet with the plusForSpace option.
These octets all go directly into the URL, all others are escaped.
java.net.URLEncoder uses upper-case hex digits so we should too.
This method is deprecated.
Use uriEscaper().
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
Instead of retrieving this set to add your own safe characters, simply
provide your additional safe characters to the
PercentEscaper(String, boolean) constructor.
If you don't need to add your own safe characters, just use
uriEscaper().
encode(String, String, BitSet, boolean) or
encode(String, BitSet, boolean). It defaults to containing the
octets that would not be escaped by
encode(String). Callers can edit the
result for specialized purposes.
This method is deprecated.
Use uriEscaper()
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
URL-escapes s by encoding it with the specified character encoding, escaping all octets not included in safeOctets, and then outputting the result to an Appendable.
| s | String to encode. |
|---|---|
| encoding | Character encoding to use (e.g., "UTF-8") |
| safeOctets | Set of octets that should not be escaped. |
| plusForSpace | Whether octet 0x20, i.e. "space", should be encoded as a plus sign rather than "%20". Note that this parameter is effectively ignored if 0x20 is in safeOctets. |
| out | The Appendable destination for the encoded string. |
s did need escaping, false otherwise. In
other words, this returns false only if s was output to
out verbatim.| UnsupportedEncodingException | if encoding is not supported. |
|---|---|
| IOException | if out does so when appended to. |
This method is deprecated.
Use uriEscaper().
See FastURLEncoder for more details.
Shortcut for encode(s, "UTF-8", out). This is very similiar to java.net.URLEncoder.encode() except that it uses UTF-8 instead of the platform's default encoding.
| s | String to encode. |
|---|---|
| out | The Appendable destination for the encoded string. |
| IOException |
|---|
This method is deprecated.
Use uriEscaper()
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
URL-escapes s by encoding it with the specified character encoding, and then escaping all octets not included in safeOctets.
| s | String to encode. |
|---|---|
| encoding | Character encoding to use (e.g., "UTF-8") |
| safeOctets | Set of octets that should not be escaped. |
| plusForSpace | Whether octet 0x20, i.e. "space", should be encoded as a plus sign rather than "%20". Note that this parameter is effectively ignored if 0x20 is in safeOctets. |
s. Will return s
itself if no encoding is necessary.| UnsupportedEncodingException | if encoding is not supported. |
|---|
This method is deprecated.
Use uriEscaper().
See FastURLEncoder for more details.
This should be a direct replacement for java.net.URLEncoder.encode(), but appends its output to an Appendable.
| s | String to encode. |
|---|---|
| encoding | Character encoding to use (e.g., "UTF-8") |
| out | The Appendable destination for the encoded string. |
| UnsupportedEncodingException | if encoding is not supported. |
|---|---|
| IOException | if out does so when appended to. |
This method is deprecated.
Use uriEscaper().
See FastURLEncoder for more details.
This should be a direct replacement for java.net.URLEncoder.encode().
| s | String to encode. |
|---|---|
| encoding | Character encoding to use (e.g., "UTF-8") |
| UnsupportedEncodingException |
|---|
This method is deprecated.
Use uriEscaper().
or create an instance of PercentEscaper.
See FastURLEncoder for more details.
Shortcut for encode(s, "UTF-8"). This is very similiar to java.net.URLEncoder.encode() except that it uses UTF-8 instead of the platform's default encoding.
| s | String to encode. |
|---|---|
| safeOctets | Set of octets that should not be escaped. |
| plusForSpace | Whether octet 0x20, i.e., "space", should be encoded as a plus sign rather than "%20". Note that this parameter is effectively ignored if 0x20 is in safeOctets. |
This method is deprecated.
Use uriEscaper().
Shortcut for encode(s, "UTF-8"). This is very similiar to java.net.URLEncoder.encode() except that it uses UTF-8 instead of the platform's default encoding.
| s | String to encode. |
|---|