Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.util
Class B64Code  view B64Code download B64Code.java

java.lang.Object
  extended byorg.mortbay.util.B64Code

public class B64Code
extends java.lang.Object

Fast B64 Encoder/Decoder as described in RFC 1421.

Does not insert or interpret whitespace as described in RFC 1521. If you require this you must pre/post process your data.

Note that in a web context the usual case is to not want linebreaks or other white space in the encoded output.

Version:
$Revision: 1.5 $

Field Summary
(package private) static byte[] code2nibble
           
(package private) static char[] nibble2code
           
(package private) static char pad
           
 
Constructor Summary
B64Code()
           
 
Method Summary
static byte[] decode(char[] b)
          Fast Base 64 decode as described in RFC 1421.
static java.lang.String decode(java.lang.String s)
          Base 64 decode as described in RFC 1421.
static java.lang.String decode(java.lang.String s, java.lang.String charEncoding)
          Base 64 decode as described in RFC 1421.
static char[] encode(byte[] b)
          Fast Base 64 encode as described in RFC 1421.
static java.lang.String encode(java.lang.String s)
          Base 64 encode as described in RFC 1421.
static java.lang.String encode(java.lang.String s, java.lang.String charEncoding)
          Base 64 encode as described in RFC 1421.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pad

static final char pad
See Also:
Constant Field Values

nibble2code

static final char[] nibble2code

code2nibble

static byte[] code2nibble
Constructor Detail

B64Code

public B64Code()
Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.


encode

public static java.lang.String encode(java.lang.String s,
                                      java.lang.String charEncoding)
                               throws java.io.UnsupportedEncodingException
Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.


encode

public static char[] encode(byte[] b)
Fast Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.

Avoids creating extra copies of the input/output.


decode

public static java.lang.String decode(java.lang.String s)
Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.


decode

public static java.lang.String decode(java.lang.String s,
                                      java.lang.String charEncoding)
                               throws java.io.UnsupportedEncodingException
Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.


decode

public static byte[] decode(char[] b)
Fast Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.

Avoids creating extra copies of the input/output.

Note this code has been flattened for performance.