Package org.codehaus.stax2.ri.typed
Class StringBase64Decoder
- java.lang.Object
-
- 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
Constructors Constructor Description StringBase64Decoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
decode(byte[] resultBuffer, int resultOffset, int maxLength)
Method that does actual decodingbyte[]
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)
-
-
-
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 returnedresultOffset
- 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:- We are waiting for start of a new segment; no data to decode, ok to quit (returns 0)
- We are half-way through decoding for padding variant (or, non-padding with just partial byte [single char]); error case. (returns -1)
- We are half-way through decoding for non-padding variant, and thereby have 1 or 2 bytes of data (which was not earlier recognized because of missing padding characters) (returns 1 or 2, number of bytes made available)
-
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
-
-