Class URL
- java.lang.Object
-
- com.google.gwt.http.client.URL
-
public final class URL extends java.lang.ObjectUtility class for the encoding and decoding URLs in their entirety or by their individual components.Required Module
Modules that use this class should inheritcom.google.gwt.http.HTTP.<module> <!-- other inherited modules, such as com.google.gwt.user.User --> <inherits name="com.google.gwt.http.HTTP"/> <!-- additional module settings --> </module>
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.Stringdecode(java.lang.String encodedURL)Returns a string where all URL escape sequences have been converted back to their original character representations.static java.lang.StringdecodeComponent(java.lang.String encodedURLComponent)Deprecated.static java.lang.StringdecodeComponent(java.lang.String encodedURLComponent, boolean fromQueryString)Deprecated.static java.lang.StringdecodePathSegment(java.lang.String encodedURLComponent)Returns a string where all URL component escape sequences have been converted back to their original character representations.static java.lang.StringdecodeQueryString(java.lang.String encodedURLComponent)Returns a string where all URL component escape sequences have been converted back to their original character representations.static java.lang.Stringencode(java.lang.String decodedURL)Returns a string where all characters that are not valid for a complete URL have been escaped.static java.lang.StringencodeComponent(java.lang.String decodedURLComponent)Deprecated.static java.lang.StringencodeComponent(java.lang.String decodedURLComponent, boolean queryStringSpaces)Deprecated.static java.lang.StringencodePathSegment(java.lang.String decodedURLComponent)Returns a string where all characters that are not valid for a URL component have been escaped.static java.lang.StringencodeQueryString(java.lang.String decodedURLComponent)Returns a string where all characters that are not valid for a URL component have been escaped.
-
-
-
Method Detail
-
decode
public static java.lang.String decode(java.lang.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- Returns:
- string with no encoded URL encoded sequences
- Throws:
java.lang.NullPointerException- if encodedURL isnull
-
decodeComponent
@Deprecated public static java.lang.String decodeComponent(java.lang.String encodedURLComponent)
Deprecated.Returns a string where all URL component escape sequences have been converted back to their original character representations.Note: this method will convert the space character escape short form, '+', into a space. It should therefore only be used for query-string parts.
- Parameters:
encodedURLComponent- string containing encoded URL component sequences- Returns:
- string with no encoded URL component encoded sequences
- Throws:
java.lang.NullPointerException- if encodedURLComponent isnull
-
decodeComponent
@Deprecated public static java.lang.String decodeComponent(java.lang.String encodedURLComponent, boolean fromQueryString)Deprecated.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 sequencesfromQueryString- iftrue, +'s will be turned into spaces, otherwise they'll be kept as-is.- Returns:
- string with no encoded URL component encoded sequences
- Throws:
java.lang.NullPointerException- if encodedURLComponent isnull
-
decodePathSegment
public static java.lang.String decodePathSegment(java.lang.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- Returns:
- string with no encoded URL component encoded sequences
- Throws:
java.lang.NullPointerException- if encodedURLComponent isnull
-
decodeQueryString
public static java.lang.String decodeQueryString(java.lang.String encodedURLComponent)
Returns a string where all URL component escape sequences have been converted back to their original character representations.Note: this method will convert the space character escape short form, '+', into a space. It should therefore only be used for query-string parts.
- Parameters:
encodedURLComponent- string containing encoded URL component sequences- Returns:
- string with no encoded URL component encoded sequences
- Throws:
java.lang.NullPointerException- if encodedURLComponent isnull
-
encode
public static java.lang.String encode(java.lang.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:
- ASCII digits or letters
- ASCII punctuation characters:
- _ . ! ~ * ' ( )
- URL component delimiter characters:
; / ? : & = + $ , #
- Parameters:
decodedURL- a string containing URL characters that may require encoding- Returns:
- a string with all invalid URL characters escaped
- Throws:
java.lang.NullPointerException- if decodedURL isnull
-
encodeComponent
@Deprecated public static java.lang.String encodeComponent(java.lang.String decodedURLComponent)
Deprecated.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.Note: this method will convert any the space character into its escape short form, '+' rather than %20. It should therefore only be used for query-string parts.
The following character sets are not escaped by this method:
- ASCII digits or letters
- ASCII punctuation characters:
- _ . ! ~ * ' ( )
Notice that this method does encode the URL component delimiter characters:
; / ? : & = + $ , #
- Parameters:
decodedURLComponent- a string containing invalid URL characters- Returns:
- a string with all invalid URL characters escaped
- Throws:
java.lang.NullPointerException- if decodedURLComponent isnull
-
encodeComponent
@Deprecated public static java.lang.String encodeComponent(java.lang.String decodedURLComponent, boolean queryStringSpaces)Deprecated.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:
- ASCII digits or letters + *
- ASCII punctuation characters:
- _ . ! ~ * ' ( )
Notice that this method does encode the URL component delimiter characters:
; / ? : & = + $ , #
- Parameters:
decodedURLComponent- a string containing invalid URL charactersqueryStringSpaces- iftrue, spaces will be encoded as +'s.- Returns:
- a string with all invalid URL characters escaped
- Throws:
java.lang.NullPointerException- if decodedURLComponent isnull
-
encodePathSegment
public static java.lang.String encodePathSegment(java.lang.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:
- ASCII digits or letters
- ASCII punctuation characters:
- _ . ! ~ * ' ( )
Notice that this method does encode the URL component delimiter characters:
; / ? : & = + $ , #
- Parameters:
decodedURLComponent- a string containing invalid URL characters- Returns:
- a string with all invalid URL characters escaped
- Throws:
java.lang.NullPointerException- if decodedURLComponent isnull
-
encodeQueryString
public static java.lang.String encodeQueryString(java.lang.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.Note: this method will convert any the space character into its escape short form, '+' rather than %20. It should therefore only be used for query-string parts.
The following character sets are not escaped by this method:
- ASCII digits or letters
- ASCII punctuation characters:
- _ . ! ~ * ' ( )
Notice that this method does encode the URL component delimiter characters:
; / ? : & = + $ , #
- Parameters:
decodedURLComponent- a string containing invalid URL characters- Returns:
- a string with all invalid URL characters escaped
- Throws:
java.lang.NullPointerException- if decodedURLComponent isnull
-
-