org.ajax4jsf.util.base64

## Class URLCodec

- java.lang.Object
- - org.ajax4jsf.util.base64.URLCodec

- All Implemented Interfaces:
    BinaryDecoder, BinaryEncoder, Decoder, Encoder

      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.

  Since:
    1.2
  Version:
    $Id: URLCodec.java,v 1.1.2.1 2007/01/09 18:59:14 alexsmirnov Exp $
  Author:
    Apache Software Foundation

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `URLCodec()` Default constructor.

  - ### Method Summary

    Methods
    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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ESCAPE_CHAR

          protected static final byte ESCAPE_CHAR

      See Also:
        Constant Field Values

    - #### WWW_FORM_URL

          protected static final BitSet WWW_FORM_URL

      BitSet of www-form-url safe characters.

  - ### Constructor Detail

    - #### URLCodec

          public URLCodec()

      Default constructor.

  - ### Method Detail

    - #### encodeUrl

          public static final byte[] encodeUrl(byte[] bytes)

    - #### encodeUrl

          public static final byte[] encodeUrl(BitSet urlsafe,
                         byte[] bytes)

      Encodes an array of bytes into an array of URL safe 7-bit

      characters. Unsafe characters are escaped.
      Parameters:
        `urlsafe` - bitset of characters deemed URL safe
        `bytes` - array of bytes to convert to URL safe characters
      Returns:
        array of bytes containing URL safe characters

    - #### decodeUrl

          public static final byte[] decodeUrl(byte[] bytes)
                                        throws DecoderException

      Decodes an array of URL safe 7-bit characters into an array of

      original bytes. Escaped characters are converted back to their

      original representation.
      Parameters:
        `bytes` - array of URL safe characters
      Returns:
        array of original bytes
      Throws:
        `DecoderException` - Thrown if URL decoding is unsuccessful

    - #### encode

          public byte[] encode(byte[] bytes)

      Encodes an array of bytes into an array of URL safe 7-bit

      characters. Unsafe characters are escaped.
      Specified by:
        `encode` in interface `BinaryEncoder`
      Parameters:
        `bytes` - array of bytes to convert to URL safe characters
      Returns:
        array of bytes containing URL safe characters

    - #### decode

          public byte[] decode(byte[] bytes)
                        throws DecoderException

      Decodes an array of URL safe 7-bit characters into an array of

      original bytes. Escaped characters are converted back to their

      original representation.
      Specified by:
        `decode` in interface `BinaryDecoder`
      Parameters:
        `bytes` - array of URL safe characters
      Returns:
        array of original bytes
      Throws:
        `DecoderException` - Thrown if URL decoding is unsuccessful

    - #### encode

          public Object encode(Object pObject)
                        throws EncoderException

      Encodes an object into its URL safe form. Unsafe characters are

      escaped.
      Specified by:
        `encode` in interface `Encoder`
      Parameters:
        `pObject` - string to convert to a URL safe form
      Returns:
        URL safe object
      Throws:
        `EncoderException` - Thrown if URL encoding is not

        applicable to objects of this type or

        if encoding is unsuccessful

    - #### decode

          public Object decode(Object pObject)
                        throws DecoderException

      Decodes a URL safe object into its original form. Escaped

      characters are converted back to their original representation.
      Specified by:
        `decode` in interface `Decoder`
      Parameters:
        `pObject` - URL safe object to convert into its original form
      Returns:
        original object
      Throws:
        `DecoderException` - Thrown if URL decoding is not

        applicable to objects of this type

        if decoding is unsuccessful

Copyright © 2014 JBoss by Red Hat. All Rights Reserved.