public class URLCodec extends Object implements BinaryEncoder, BinaryDecoder
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
URLEncoder
and URLDecoder
on older Java platforms, as these classes in Java versions below
1.4 rely on the platform's default charset encoding.
Modifier and Type | Field and Description |
---|---|
protected static byte |
ESCAPE_CHAR |
protected static BitSet |
WWW_FORM_URL
BitSet of www-form-url safe characters.
|
Constructor and Description |
---|
URLCodec()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(byte[] bytes)
Decodes an array of URL safe 7-bit characters into an array of
original bytes.
|
Object |
decode(Object pObject)
Decodes a URL safe object into its original form.
|
static byte[] |
decodeUrl(byte[] bytes)
Decodes an array of URL safe 7-bit characters into an array of
original bytes.
|
byte[] |
encode(byte[] bytes)
Encodes an array of bytes into an array of URL safe 7-bit
characters.
|
Object |
encode(Object pObject)
Encodes an object into its URL safe form.
|
static byte[] |
encodeUrl(BitSet urlsafe,
byte[] bytes)
Encodes an array of bytes into an array of URL safe 7-bit
characters.
|
static byte[] |
encodeUrl(byte[] bytes) |
protected static final byte ESCAPE_CHAR
protected static final BitSet WWW_FORM_URL
public static final byte[] encodeUrl(byte[] bytes)
public static final byte[] encodeUrl(BitSet urlsafe, byte[] bytes)
urlsafe
- bitset of characters deemed URL safebytes
- array of bytes to convert to URL safe characterspublic static final byte[] decodeUrl(byte[] bytes) throws DecoderException
bytes
- array of URL safe charactersDecoderException
- Thrown if URL decoding is unsuccessfulpublic byte[] encode(byte[] bytes)
encode
in interface BinaryEncoder
bytes
- array of bytes to convert to URL safe characterspublic byte[] decode(byte[] bytes) throws DecoderException
decode
in interface BinaryDecoder
bytes
- array of URL safe charactersDecoderException
- Thrown if URL decoding is unsuccessfulpublic Object encode(Object pObject) throws EncoderException
encode
in interface Encoder
pObject
- string to convert to a URL safe formEncoderException
- Thrown if URL encoding is not
applicable to objects of this type or
if encoding is unsuccessfulpublic Object decode(Object pObject) throws DecoderException
decode
in interface Decoder
pObject
- URL safe object to convert into its original formDecoderException
- Thrown if URL decoding is not
applicable to objects of this type
if decoding is unsuccessfulCopyright © 2014 JBoss by Red Hat. All Rights Reserved.