Class Base64Decoder

java.lang.Object
org.djutils.decoderdumper.Base64Decoder
All Implemented Interfaces:
Decoder

public class Base64Decoder
extends Object
implements Decoder
Decode base64 encoded data and show it as hex bytes. See https://en.wikipedia.org/wiki/Base64

Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version Jan 7, 2019
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Constructor Summary

    Constructors 
    Constructor Description
    Base64Decoder​(int decodedBytesPerLine, int extraSpaceAfterEvery)
    Construct a new Base64Decoder.
  • Method Summary

    Modifier and Type Method Description
    boolean append​(int address, byte theByte)
    Decode one (more) byte.
    int getMaximumWidth()
    Retrieve the maximum width (in characters) of results that this Decoder can return (all shorter results will be padded to this width with spaces, unless this is the last active Decoder).
    String getResult()
    Retrieve the current result of this Decoder.
    boolean ignoreForIdenticalOutputCheck()
    If the result of this Decoder should not be used to compare output lines for suppressing identical lines, this method should return true; otherwise it should return false.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Base64Decoder

      public Base64Decoder​(int decodedBytesPerLine, int extraSpaceAfterEvery)
      Construct a new Base64Decoder.
      Parameters:
      decodedBytesPerLine - int; maximum number of decoded input characters resulting in one output line
      extraSpaceAfterEvery - int; insert an extra space after every N output fields (a multiple of 3 makes sense for the base64 decoder because base64 encodes three bytes into 4 characters)
  • Method Details

    • getResult

      public String getResult()
      Retrieve the current result of this Decoder. Decoders that handle multiple byte input may be somewhere within a token. Such Decoders should report a partial result. If no data has been added, the result must be the empty string.
      Specified by:
      getResult in interface Decoder
      Returns:
      String; the current result of this Decoder
    • getMaximumWidth

      public int getMaximumWidth()
      Retrieve the maximum width (in characters) of results that this Decoder can return (all shorter results will be padded to this width with spaces, unless this is the last active Decoder).
      Specified by:
      getMaximumWidth in interface Decoder
      Returns:
      int; the maximum width (in characters) of results that this Decoder can return
    • append

      public boolean append​(int address, byte theByte) throws IOException
      Decode one (more) byte. This method must return true when a line becomes full due to this call, otherwise this method must return false.
      Specified by:
      append in interface Decoder
      Parameters:
      address - int; the address that corresponds with the byte
      theByte - byte; the byte
      Returns:
      boolean; true if an output line has been completed by this call; false if at least one more byte can be appended to the local accumulator before the current output line is full
      Throws:
      IOException - when the output device throws this exception
    • ignoreForIdenticalOutputCheck

      public boolean ignoreForIdenticalOutputCheck()
      If the result of this Decoder should not be used to compare output lines for suppressing identical lines, this method should return true; otherwise it should return false.
      Specified by:
      ignoreForIdenticalOutputCheck in interface Decoder
      Returns:
      boolean; true if the result of this Decoder should be ignored in testing for identical output lines; otherwise false