org.castor.util
Class Base64Encoder

java.lang.Object
  extended by org.castor.util.Base64Encoder

public final class Base64Encoder
extends java.lang.Object

Class encodes the bytes written to the OutPutStream to a Base64 encoded string. The encoded string can be retrieved by as a whole by the toString() method or splited into lines of 72 characters by the toStringArray() method.

Since:
0.9.9
Version:
$Revision: 1.1 $ $Date: 2005/08/05 19:58:36 $
Author:
Ralf Joachim

Constructor Summary
Base64Encoder()
          Construct a Base64Encoder.
 
Method Summary
static char[] encode(byte[] bytes)
          Encode given byte array into a encoded character array.
 char[] getCharArray()
          Get Base64 encoded characters as an array.
 void reset()
          Reset Base64Encoder to its initial state.
 void translate(byte[] bytes)
          Translate all bytes of given array by appending each to octet buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64Encoder

public Base64Encoder()
Construct a Base64Encoder.

Method Detail

encode

public static char[] encode(byte[] bytes)
Encode given byte array into a encoded character array.

Parameters:
bytes - The byte array to be encoded.
Returns:
Base64 encoded characters as an array.

reset

public void reset()
Reset Base64Encoder to its initial state. Take care using this method as it throws all previously written bytes away.


translate

public void translate(byte[] bytes)
Translate all bytes of given array by appending each to octet buffer. If buffer contains 3 octets its content will be encoded to 4 sextet byte values which are converted to a base64 character each. All characters are appended to a StringBuffer.

Parameters:
bytes - The byte array to be encoded.

getCharArray

public char[] getCharArray()
Get Base64 encoded characters as an array.

Returns:
Base64 encoded characters as an array.


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com