org.codehaus.stax2.ri.typed
Class StringBase64Decoder

java.lang.Object
  extended by org.codehaus.stax2.ri.typed.StringBase64Decoder

public final class StringBase64Decoder
extends Object

Base64 decoder that can be used to decode base64 encoded content that is passed as a Single string.


Constructor Summary
StringBase64Decoder()
           
 
Method Summary
 int decode(byte[] resultBuffer, int resultOffset, int maxLength)
          Method that does actual decoding
 byte[] decodeCompletely()
          Method that can be called to completely decode content that this decoder has been initialized with.
 int endOfContent()
          Method called to indicate that we have no more encoded content to process, and decoding is to finish.
 Stax2Util.ByteAggregator getByteAggregator()
           
 boolean hasData()
          Method that can be called to check if this decoder is in has unflushed data ready to be returned.
 void init(Base64Variant variant, boolean firstChunk, String segment)
           
protected  IllegalArgumentException reportInvalidChar(char ch, int bindex)
           
protected  IllegalArgumentException reportInvalidChar(char ch, int bindex, String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringBase64Decoder

public StringBase64Decoder()
Method Detail

init

public void init(Base64Variant variant,
                 boolean firstChunk,
                 String segment)

decode

public int decode(byte[] resultBuffer,
                  int resultOffset,
                  int maxLength)
           throws IllegalArgumentException
Method that does actual decoding

Parameters:
resultBuffer - Buffer in which decoded bytes are returned
resultOffset - Offset that points to position to put the first decoded byte in maxLength Maximum number of bytes that can be returned in given buffer
Returns:
Number of bytes decoded and returned in the result buffer
Throws:
IllegalArgumentException

hasData

public final boolean hasData()
Method that can be called to check if this decoder is in has unflushed data ready to be returned.


endOfContent

public final int endOfContent()
Method called to indicate that we have no more encoded content to process, and decoding is to finish. Depending base64 variant in use, this means one of three things:


decodeCompletely

public byte[] decodeCompletely()
Method that can be called to completely decode content that this decoder has been initialized with.


getByteAggregator

public Stax2Util.ByteAggregator getByteAggregator()

reportInvalidChar

protected IllegalArgumentException reportInvalidChar(char ch,
                                                     int bindex)
                                              throws IllegalArgumentException
Throws:
IllegalArgumentException

reportInvalidChar

protected IllegalArgumentException reportInvalidChar(char ch,
                                                     int bindex,
                                                     String msg)
                                              throws IllegalArgumentException
Parameters:
bindex - Relative index within base64 character unit; between 0 and 3 (as unit has exactly 4 characters)
Throws:
IllegalArgumentException