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:
java.util.function.Supplier<Base64>
- Enclosing class:
- Base64
public static class Base64.Builder extends BaseNCodec.AbstractBuilder<Base64,Base64.Builder>
BuildsBase64instances.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Base64get()Base64.BuildersetDecodeTableFormat(Base64.DecodeTableFormat format)Sets the format of the decoding table.Base64.BuildersetEncodeTable(byte... encodeTable)Sets the encode table.Base64.BuildersetUrlSafe(boolean urlSafe)Sets the URL-safe encoding policy.-
Methods inherited from class org.apache.commons.codec.binary.BaseNCodec.AbstractBuilder
setDecodeTable, setDecodingPolicy, setLineLength, setLineSeparator, setPadding
-
-
-
-
Constructor Detail
-
Builder
public Builder()
Constructs a new instance.
-
-
Method Detail
-
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 usesetUrlSafe(boolean)method.By default, the implementation uses the
Base64.DecodeTableFormat.MIXEDapproach, allowing a seamless handling of bothBase64.DecodeTableFormat.URL_SAFEandBase64.DecodeTableFormat.STANDARDbase64.- Parameters:
format- table format to be used on Base64 decoding. UseBase64.DecodeTableFormat.MIXEDor null to reset to the default behavior.- Returns:
thisinstance.- Since:
- 1.21
-
setEncodeTable
public Base64.Builder setEncodeTable(byte... encodeTable)
Description copied from class:BaseNCodec.AbstractBuilderSets the encode table.- Overrides:
setEncodeTablein classBaseNCodec.AbstractBuilder<Base64,Base64.Builder>- Parameters:
encodeTable- the encode table, null resets to the default.- Returns:
thisinstance.
-
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, null resets to the default.- Returns:
thisinstance.
-
-