Class Base64Options

java.lang.Object
dev.frostlake.functions.scalar.encoding.Base64Options

public final class Base64Options extends Object
The optional arguments the base64 family carries beyond its input.

BASE64_ENCODE takes up to three: the value, a MAX LINE LENGTH that wraps the encoded text, and an ALPHABET whose two characters stand in for the standard + and /. The decoders take the alphabet as their second argument so a custom encoding can be read back — BASE64_DECODE_BINARY(BASE64_ENCODE(b, 0, '$%'), '$%') round-trips, while decoding the same text with the standard alphabet is an error, because $ and % are not base64.

A line length of 0 means no wrapping, which is the default. Wrapping inserts a newline every N characters with none left trailing, so a 14-group encoding at width 8 carries 13 newlines.

  • Method Details

    • alphabetOf

      public static String alphabetOf(List<Object> args, int index)
      The alphabet argument at index, or the standard +/ when it is not given.
    • lineLengthOf

      public static int lineLengthOf(List<Object> args, int index)
      The max-line-length argument at index, or 0 — no wrapping — when it is not given.

      A fractional length is ROUNDED rather than truncated, half away from zero, which is visible in the output: a length of 8.7 wraps at NINE characters and one of 1.5 at two. Anything that rounds to zero or below wraps nothing — a negative length reaching this point is not an error, it is no wrapping. A length that does not fit a 32-bit integer IS an error, and live names the ROUNDED value in it.

      The compile-time half of the rule lives in the expression walk, which refuses an integral numeric LITERAL outside [0, 2147483647] before a row is read. The halves do not overlap: such a literal never reaches here, and everything else is only ever judged here.

    • toCustomAlphabet

      public static String toCustomAlphabet(String standard, String alphabet)
      Standard base64 output rewritten into the caller's alphabet.
    • toStandardAlphabet

      public static String toStandardAlphabet(String text, String alphabet)
      The caller's alphabet rewritten back to standard base64, ready to decode.
    • wrap

      public static String wrap(String encoded, int maxLineLength)
      The encoded text broken into lines of maxLineLength, or unchanged when that is 0.
    • notBase64

      public static RuntimeException notBase64(String text)
      The refusal for text that is not base64 once its alphabet has been normalised.