Class URL

public final class URL
extends Object
Utility class for the encoding and decoding URLs in their entirety or by their individual components.

Required Module

Modules that use this class should inherit com.google.gwt.http.HTTP.
<!--                                                                        -->
<!-- Copyright 2007 Google Inc.                                             -->
<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
<!-- may not use this file except in compliance with the License. You may   -->
<!-- may obtain a copy of the License at                                    -->
<!--                                                                        -->
<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
<!--                                                                        -->
<!-- Unless required by applicable law or agreed to in writing, software    -->
<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
<!-- implied. License for the specific language governing permissions and   -->
<!-- limitations under the License.                                         -->

<module>
  <!-- other inherited modules, such as com.google.gwt.user.User -->
  <inherits name="com.google.gwt.http.HTTP"/>
  <!-- additional module settings -->
</module>

Methods

decode(String)Returns a string where all URL escape sequences have been converted back to their original character representations.
decodeComponent(String)Returns a string where all URL component escape sequences have been converted back to their original character representations.
encode(String)Returns a string where all characters that are not valid for a complete URL have been escaped.
encodeComponent(String)Returns a string where all characters that are not valid for a URL component have been escaped.

Method Detail

decode

public static String decode(String encodedURL)
Returns a string where all URL escape sequences have been converted back to their original character representations.

Parameters

encodedURL
string containing encoded URL encoded sequences

Return Value

string with no encoded URL encoded sequences

decodeComponent

public static String decodeComponent(String encodedURLComponent)
Returns a string where all URL component escape sequences have been converted back to their original character representations.

Parameters

encodedURLComponent
string containing encoded URL component sequences

Return Value

string with no encoded URL component encoded sequences

encode

public static String encode(String decodedURL)
Returns a string where all characters that are not valid for a complete URL have been escaped. The escaping of a character is done by converting it into its UTF-8 encoding and then encoding each of the resulting bytes as a %xx hexadecimal escape sequence.

The following character sets are not escaped by this method:

Parameters

decodedURL
a string containing URL characters that may require encoding

Return Value

a string with all invalid URL characters escaped

encodeComponent

public static String encodeComponent(String decodedURLComponent)
Returns a string where all characters that are not valid for a URL component have been escaped. The escaping of a character is done by converting it into its UTF-8 encoding and then encoding each of the resulting bytes as a %xx hexadecimal escape sequence.

The following character sets are not escaped by this method:

Notice that this method does encode the URL component delimiter characters:

 ; / ? : & = + $ , #
 

Parameters

decodedURLComponent
a string containing invalid URL characters

Return Value

a string with all invalid URL characters escaped