Implements the 'www-form-urlencoded' encoding scheme, also misleadingly known as URL encoding.
For more detailed information please refer to Chapter 17.13.4 'Form content types' of the HTML 4.01 Specification.
This codec is meant to be a replacement for standard Java classes {Javadoc_link java.net.URLEncoder} and {Javadoc_link java.net.URLDecoder} on older Java platforms, as these classes in Java versions below 1.4 rely on the platform's default charset encoding.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You 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. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
URLCodec () | |
Default constructor. | |
URLCodec (String charset) | |
Constructor which allows for the selection of a default charset. More... | |
byte[] | encode (byte[] bytes) |
Encodes an array of bytes into an array of URL safe 7-bit characters. More... | |
byte[] | decode (byte[] bytes) throws DecoderException |
Decodes an array of URL safe 7-bit characters into an array of original bytes. More... | |
String | encode (String pString, String charset) throws UnsupportedEncodingException |
Encodes a string into its URL safe form using the specified string charset. More... | |
String | encode (String pString) throws EncoderException |
Encodes a string into its URL safe form using the default string charset. More... | |
String | decode (String pString, String charset) throws DecoderException, UnsupportedEncodingException |
Decodes a URL safe string into its original form using the specified encoding. More... | |
String | decode (String pString) throws DecoderException |
Decodes a URL safe string into its original form using the default string charset. More... | |
Object | encode (Object pObject) throws EncoderException |
Encodes an object into its URL safe form. More... | |
Object | decode (Object pObject) throws DecoderException |
Decodes a URL safe object into its original form. More... | |
String | getEncoding () |
The String encoding used for decoding and encoding. More... | |
String | getDefaultCharset () |
The default charset used for string decoding and encoding. More... | |
Static Public Member Functions | |
static final byte[] | encodeUrl (BitSet urlsafe, byte[] bytes) |
Encodes an array of bytes into an array of URL safe 7-bit characters. More... | |
static final byte[] | decodeUrl (byte[] bytes) throws DecoderException |
Decodes an array of URL safe 7-bit characters into an array of original bytes. More... | |
Protected Attributes | |
String | charset = StringEncodings.UTF8 |
The default charset used for string decoding and encoding. | |
Static Protected Attributes | |
static final BitSet | WWW_FORM_URL = new BitSet(256) |
BitSet of www-form-url safe characters. | |
URLCodec | ( | String | charset | ) |
charset | the default string charset to use. |
|
static |
Unsafe characters are escaped.
urlsafe | bitset of characters deemed URL safe |
bytes | array of bytes to convert to URL safe characters |
|
static |
Escaped characters are converted back to their original representation.
bytes | array of URL safe characters |
DecoderException | Thrown if URL decoding is unsuccessful |
byte [] encode | ( | byte[] | bytes | ) |
Unsafe characters are escaped.
bytes | array of bytes to convert to URL safe characters |
Implements BinaryEncoder.
byte [] decode | ( | byte[] | bytes | ) | throws DecoderException |
Escaped characters are converted back to their original representation.
bytes | array of URL safe characters |
DecoderException | Thrown if URL decoding is unsuccessful |
Implements BinaryDecoder.
String encode | ( | String | pString, |
String | charset | ||
) | throws UnsupportedEncodingException |
Unsafe characters are escaped.
pString | string to convert to a URL safe form |
charset | the charset for pString |
UnsupportedEncodingException | Thrown if charset is not supported |
String encode | ( | String | pString | ) | throws EncoderException |
Unsafe characters are escaped.
pString | string to convert to a URL safe form |
EncoderException | Thrown if URL encoding is unsuccessful |
Implements StringEncoder.
String decode | ( | String | pString, |
String | charset | ||
) | throws DecoderException, UnsupportedEncodingException |
Escaped characters are converted back to their original representation.
pString | URL safe string to convert into its original form |
charset | the original string charset |
DecoderException | Thrown if URL decoding is unsuccessful |
UnsupportedEncodingException | Thrown if charset is not supported |
String decode | ( | String | pString | ) | throws DecoderException |
Escaped characters are converted back to their original representation.
pString | URL safe string to convert into its original form |
DecoderException | Thrown if URL decoding is unsuccessful |
Implements StringDecoder.
Object encode | ( | Object | pObject | ) | throws EncoderException |
Unsafe characters are escaped.
pObject | string to convert to a URL safe form |
EncoderException | Thrown if URL encoding is not applicable to objects of this type or if encoding is unsuccessful |
Implements Encoder.
Object decode | ( | Object | pObject | ) | throws DecoderException |
Escaped characters are converted back to their original representation.
pObject | URL safe object to convert into its original form |
DecoderException | Thrown if URL decoding is not applicable to objects of this type if decoding is unsuccessful |
Implements Decoder.
String getEncoding | ( | ) |
String getDefaultCharset | ( | ) |