Base64.Builder (Apache Commons Codec 1.22.1 API)
Description: declaration: package: org.apache.commons.codec.binary, class: Base64, class: Builder

Package org.apache.commons.codec.binary

# Class Base64.Builder

java.lang.Object
org.apache.commons.codec.binary.BaseNCodec.AbstractBuilder<Base64,Base64.Builder>
org.apache.commons.codec.binary.Base64.Builder

All Implemented Interfaces:
  `Supplier<Base64>`

Enclosing class:
  `Base64`

public static class Base64.Builder extends BaseNCodec.AbstractBuilder<Base64,Base64.Builder>
Builds `Base64` instances.

To configure a new instance, use a `Base64.Builder`. For example:

     Base64 base64 = Base64.builder()
       .setCodecPolicy(CodecPolicy.LENIENT)       // default is lenient, null resets to default
       .setEncodeTable(customEncodeTable)         // default is built in, null resets to default
       .setLineLength(0)                          // default is none
       .setLineSeparator('\r', '\n')              // default is CR LF, null resets to default
       .setPadding('=')                           // default is '='
       .setUrlSafe(false)                         // default is false
       .get()

Since:
  1.17.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Base64`
  `get()`
  `Base64.Builder`
  `setDecodeTableFormat(Base64.DecodeTableFormat format)`
  Sets the format of the decoding table.
  `Base64.Builder`
  `setEncodeTable(byte... encodeTable)`
  Sets the encode table.
  `Base64.Builder`
  `setUrlSafe(boolean urlSafe)`
  Sets the URL-safe encoding policy.

  ### Methods inherited from class org.apache.commons.codec.binary.BaseNCodec.AbstractBuilder

  `setDecodeTable, setDecodingPolicy, setLineLength, setLineSeparator, setPadding`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    public Builder()
    Constructs a new instance.

- ## Method Details

  - ### get

    public Base64 get()

  - ### setDecodeTableFormat

    public Base64.Builder setDecodeTableFormat(Base64.DecodeTableFormat format)
    Sets the format of the decoding table. This method allows to explicitly state whether a standard or URL-safe Base64 decoding is expected. This method does not modify behavior on encoding operations. For configuration of the encoding behavior, please use `setUrlSafe(boolean)` method.

    By default, the implementation uses the `Base64.DecodeTableFormat.MIXED` approach, allowing a seamless handling of both `Base64.DecodeTableFormat.URL_SAFE` and `Base64.DecodeTableFormat.STANDARD` base64.

    Parameters:
      `format` - table format to be used on Base64 decoding. Use `Base64.DecodeTableFormat.MIXED` or null to reset to the default behavior.
    Returns:
      `this` instance.
    Since:
      1.21

  - ### setEncodeTable

    public Base64.Builder setEncodeTable(byte... encodeTable)
    Sets the encode table.
    Overrides:
      `setEncodeTable` in class `BaseNCodec.AbstractBuilder<Base64,Base64.Builder>`
    Parameters:
      `encodeTable` - The encode table with exactly 64 unique entries, null resets to the default.
    Returns:
      `this` instance.
    Throws:
      `IllegalArgumentException` - if `encodeTable` does not contain exactly 64 unique entries.

  - ### setUrlSafe

    public Base64.Builder setUrlSafe(boolean urlSafe)
    Sets the URL-safe encoding policy.

    This method does not modify behavior on decoding operations. For configuration of the decoding behavior, please use `Builder.setDecodeTableFormat(DecodeTableFormat)` method.

    Parameters:
      `urlSafe` - URL-safe encoding policy.
    Returns:
      `this` instance.