Class CharArrayBase64Decoder


  • public class CharArrayBase64Decoder
    extends java.lang.Object
    Base64 decoder that can be used to decode base64 encoded content that is passed as char arrays.
    • 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 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, char[] lastSegment, int lastOffset, int lastLen, java.util.List<char[]> segments)  
      protected java.lang.IllegalArgumentException reportInvalidChar​(char ch, int bindex)  
      protected java.lang.IllegalArgumentException reportInvalidChar​(char ch, int bindex, java.lang.String msg)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _currSegment

        protected char[] _currSegment
        Text segment being currently processed.
      • _currSegmentPtr

        protected int _currSegmentPtr
      • _currSegmentEnd

        protected int _currSegmentEnd
      • _nextSegments

        protected final java.util.ArrayList<char[]> _nextSegments
      • _lastSegmentOffset

        protected int _lastSegmentOffset
      • _lastSegmentEnd

        protected int _lastSegmentEnd
      • _nextSegmentIndex

        protected int _nextSegmentIndex
        Pointer of the next segment to process (after current one stored in _currSegment) within _nextSegments.
    • Constructor Detail

      • CharArrayBase64Decoder

        public CharArrayBase64Decoder()
    • Method Detail

      • init

        public void init​(Base64Variant variant,
                         boolean firstChunk,
                         char[] lastSegment,
                         int lastOffset,
                         int lastLen,
                         java.util.List<char[]> segments)
      • decode

        public int decode​(byte[] resultBuffer,
                          int resultOffset,
                          int maxLength)
                   throws java.lang.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:
        java.lang.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.
      • reportInvalidChar

        protected java.lang.IllegalArgumentException reportInvalidChar​(char ch,
                                                                       int bindex)
                                                                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • reportInvalidChar

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