com.hunnysoft.jmime
Class Base64DecoderW

java.lang.Object
  extended bycom.hunnysoft.jmime.Base64DecoderW

public class Base64DecoderW
extends java.lang.Object

Class that performs base64 decoding, with input from a char array.

This class is the same as Base64Decoder, except that the input is taken from a character array, instead of a byte array. See the overview section of Base64Decoder for general information that applies to both Base64Decoder and Base64DecoderW.

See Also:
Base64Decoder

Constructor Summary
Base64DecoderW()
          Default constructor.
 
Method Summary
 ByteString decode(java.lang.String encoded)
          Performs single-step buffer-to-buffer base64 decoding.
 void decodeSegment(CharBuffer inBuf, ByteBuffer outBuf)
          Decodes data from the input buffer to the output buffer.
 void start()
          Starts a multiple-buffer decode operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64DecoderW

public Base64DecoderW()
Default constructor.

Method Detail

start

public void start()
Starts a multiple-buffer decode operation.

If you use the low-level interface for multiple-buffer decoding, you must call start to begin the decode operation. You may use a Base64DecoderW instance for many decode operations, but you must call start to begin each operation.

For more information on using the low-level interface, see the overview section for Base64Decoder.

You do not need to call this method if you use the decode(String) method for decoding.


decodeSegment

public void decodeSegment(CharBuffer inBuf,
                          ByteBuffer outBuf)
                   throws DecodeException
Decodes data from the input buffer to the output buffer.

This method is an essential part of the low-level interface and performs most of the work of decoding for the Base64DecoderW class. It takes an input buffer and an output buffer as parameters, and decodes data from the input buffer until the input buffer is empty or the output buffer is full. In other words, one of the following conditions is guaranteed to be satisfied when the method returns:

You may call the method multiple times to decode multiple buffers of input data. However, before you call the method, both of the following conditions should be true:

For more information on using the low-level interface, see the overview section for Base64Decoder.

Parameters:
inBuf - input buffer
outBuf - output buffer
Throws:
DecodeException - if the decoder detects an error

decode

public ByteString decode(java.lang.String encoded)
                  throws DecodeException
Performs single-step buffer-to-buffer base64 decoding.

To perform base64 decoding using this method, create a String containing the data you want to decode and pass it as the method's argument. The returned ByteString contains the decoded output.

This method makes it very simple to perform base64 decoding. The disadvantage of this method is that it requires all the data to be kept in memory for processing. You may use the low-level interface, described in the overview section, to perform base64 decoding of large data using limited memory.

This method uses the low-level interface internally.

Parameters:
encoded - string containing the encoded data
Returns:
byte string containing the decoded data
Throws:
DecodeException - if the decoder detects an error