public final class

Base64Variant

extends Object
java.lang.Object
   ↳ com.fasterxml.jackson.core.Base64Variant

Class Overview

Abstract base class used to define specific details of which variant of Base64 encoding/decoding is to be used. Although there is somewhat standard basic version (so-called "MIME Base64"), other variants exists, see Base64 Wikipedia entry for details.

Summary

Constants
int BASE64_VALUE_INVALID Marker used to denote ascii characters that do not correspond to a 6-bit value (in this variant), and is not used as a padding character.
int BASE64_VALUE_PADDING Marker used to denote ascii character (in decoding table) that is the padding character using this variant (if any).
Public Constructors
Base64Variant(String name, String base64Alphabet, boolean usesPadding, char paddingChar, int maxLineLength)
Base64Variant(Base64Variant base, String name, int maxLineLength)
"Copy constructor" that can be used when the base alphabet is identical to one used by another variant except for the maximum line length (and obviously, name).
Base64Variant(Base64Variant base, String name, boolean usesPadding, char paddingChar, int maxLineLength)
"Copy constructor" that can be used when the base alphabet is identical to one used by another variant, but other details (padding, maximum line length) differ
Public Methods
int decodeBase64Byte(byte b)
int decodeBase64Char(int ch)
int decodeBase64Char(char c)
String encode(byte[] input, boolean addQuotes)
Convenience method for converting given byte array as base64 encoded String using this variant's settings, optionally enclosed in double-quotes.
String encode(byte[] input)
Convenience method for converting given byte array as base64 encoded String using this variant's settings.
byte encodeBase64BitsAsByte(int value)
char encodeBase64BitsAsChar(int value)
int encodeBase64Chunk(int b24, char[] buffer, int ptr)
Method that encodes given right-aligned (LSB) 24-bit value into 4 base64 characters, stored in given result buffer.
int encodeBase64Chunk(int b24, byte[] buffer, int ptr)
Method that encodes given right-aligned (LSB) 24-bit value into 4 base64 bytes (ascii), stored in given result buffer.
void encodeBase64Chunk(StringBuilder sb, int b24)
int encodeBase64Partial(int bits, int outputBytes, byte[] buffer, int outPtr)
Method that outputs partial chunk (which only encodes one or two bytes of data).
int encodeBase64Partial(int bits, int outputBytes, char[] buffer, int outPtr)
Method that outputs partial chunk (which only encodes one or two bytes of data).
void encodeBase64Partial(StringBuilder sb, int bits, int outputBytes)
int getMaxLineLength()
String getName()
byte getPaddingByte()
char getPaddingChar()
String toString()
boolean usesPadding()
boolean usesPaddingChar(char c)
boolean usesPaddingChar(int ch)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int BASE64_VALUE_INVALID

Marker used to denote ascii characters that do not correspond to a 6-bit value (in this variant), and is not used as a padding character.

Constant Value: -1 (0xffffffff)

public static final int BASE64_VALUE_PADDING

Marker used to denote ascii character (in decoding table) that is the padding character using this variant (if any).

Constant Value: -2 (0xfffffffe)

Public Constructors

public Base64Variant (String name, String base64Alphabet, boolean usesPadding, char paddingChar, int maxLineLength)

public Base64Variant (Base64Variant base, String name, int maxLineLength)

"Copy constructor" that can be used when the base alphabet is identical to one used by another variant except for the maximum line length (and obviously, name).

public Base64Variant (Base64Variant base, String name, boolean usesPadding, char paddingChar, int maxLineLength)

"Copy constructor" that can be used when the base alphabet is identical to one used by another variant, but other details (padding, maximum line length) differ

Public Methods

public int decodeBase64Byte (byte b)

public int decodeBase64Char (int ch)

public int decodeBase64Char (char c)

Returns
  • 6-bit decoded value, if valid character;

public String encode (byte[] input, boolean addQuotes)

Convenience method for converting given byte array as base64 encoded String using this variant's settings, optionally enclosed in double-quotes.

Parameters
input Byte array to encode
addQuotes Whether to surround resulting value in double quotes or not

public String encode (byte[] input)

Convenience method for converting given byte array as base64 encoded String using this variant's settings. Resulting value is "raw", that is, not enclosed in double-quotes.

Parameters
input Byte array to encode

public byte encodeBase64BitsAsByte (int value)

public char encodeBase64BitsAsChar (int value)

public int encodeBase64Chunk (int b24, char[] buffer, int ptr)

Method that encodes given right-aligned (LSB) 24-bit value into 4 base64 characters, stored in given result buffer.

public int encodeBase64Chunk (int b24, byte[] buffer, int ptr)

Method that encodes given right-aligned (LSB) 24-bit value into 4 base64 bytes (ascii), stored in given result buffer.

public void encodeBase64Chunk (StringBuilder sb, int b24)

public int encodeBase64Partial (int bits, int outputBytes, byte[] buffer, int outPtr)

Method that outputs partial chunk (which only encodes one or two bytes of data). Data given is still aligned same as if it as full data; that is, missing data is at the "right end" (LSB) of int.

Parameters
outputBytes Number of encoded bytes included (either 1 or 2)

public int encodeBase64Partial (int bits, int outputBytes, char[] buffer, int outPtr)

Method that outputs partial chunk (which only encodes one or two bytes of data). Data given is still aligned same as if it as full data; that is, missing data is at the "right end" (LSB) of int.

Parameters
outputBytes Number of encoded bytes included (either 1 or 2)

public void encodeBase64Partial (StringBuilder sb, int bits, int outputBytes)

public int getMaxLineLength ()

public String getName ()

public byte getPaddingByte ()

public char getPaddingChar ()

public String toString ()

public boolean usesPadding ()

public boolean usesPaddingChar (char c)

public boolean usesPaddingChar (int ch)