private Base64()

in src/main/java/org/apache/commons/codec/binary/Base64.java [664:698]


    private Base64(final int lineLength, final byte[] lineSeparator, final byte padding, final byte[] encodeTable, final CodecPolicy decodingPolicy) {
        super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);
        Objects.requireNonNull(encodeTable, "encodeTable");
        if (encodeTable.length != STANDARD_ENCODE_TABLE.length) {
            throw new IllegalArgumentException("encodeTable must have exactly 64 entries.");
        }
        this.isUrlSafe = encodeTable == URL_SAFE_ENCODE_TABLE;
        if (encodeTable == STANDARD_ENCODE_TABLE || this.isUrlSafe) {
            decodeTable = DECODE_TABLE;
            // No need of a defensive copy of an internal table.
            this.encodeTable = encodeTable;
        } else {
            this.encodeTable = encodeTable.clone();
            this.decodeTable = calculateDecodeTable(this.encodeTable);
        }
        // TODO could be simplified if there is no requirement to reject invalid line sep when length <=0
        // @see test case Base64Test.testConstructors()
        if (lineSeparator != null) {
            final byte[] lineSeparatorCopy = lineSeparator.clone();
            if (containsAlphabetOrPad(lineSeparatorCopy)) {
                final String sep = StringUtils.newStringUtf8(lineSeparatorCopy);
                throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]");
            }
            if (lineLength > 0) { // null line-sep forces no chunking rather than throwing IAE
                this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparatorCopy.length;
                this.lineSeparator = lineSeparatorCopy;
            } else {
                this.encodeSize = BYTES_PER_ENCODED_BLOCK;
                this.lineSeparator = null;
            }
        } else {
            this.encodeSize = BYTES_PER_ENCODED_BLOCK;
            this.lineSeparator = null;
        }
    }