Class CharArrayBase64Decoder

java.lang.Object
org.codehaus.stax2.ri.typed.CharArrayBase64Decoder

public class CharArrayBase64Decoder extends Object
Base64 decoder that can be used to decode base64 encoded content that is passed as char arrays.
  • Field Details

    • _currSegment

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

      protected int _currSegmentPtr
    • _currSegmentEnd

      protected int _currSegmentEnd
    • _nextSegments

      protected final 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 Details

    • CharArrayBase64Decoder

      public CharArrayBase64Decoder()
  • Method Details

    • init

      public void init(Base64Variant variant, boolean firstChunk, char[] lastSegment, int lastOffset, int lastLen, List<char[]> segments)
    • 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:
      • 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