Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34d472b7 authored by Doug Zongker's avatar Doug Zongker
Browse files

add explicit Base64.DEFAULT flag to request default behavior

Also fix some grammar problems in the javadoc, and prevent the class
from being instantiated.

Change-Id: I4d83184236566a1e77d5f5cce1c4dd3776bcfca3
parent 54ad88ea
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -21,6 +21,11 @@ package com.android.common;
 * 2045 and 3548.
 */
public class Base64 {
    /**
     * Default values for encoder/decoder flags.
     */
    public static final int DEFAULT = 0;

    /**
     * Encoder flag bit to indicate you want the padding '='
     * characters at the end (if any) to be omitted.
@@ -106,7 +111,7 @@ public class Base64 {
     * @param input the input String to decode, which is converted to
     *               bytes using the default charset
     * @param flags  controls certain features of the decoded output.
     *               Passing 0 to decode standard Base64.
     *               Pass {@code DEFAULT} to decode standard Base64.
     *
     * @throws IllegalArgumentException if the input contains
     * incorrect padding
@@ -124,7 +129,7 @@ public class Base64 {
     *
     * @param input the input array to decode
     * @param flags  controls certain features of the decoded output.
     *               Passing 0 to decode standard Base64.
     *               Pass {@code DEFAULT} to decode standard Base64.
     *
     * @throws IllegalArgumentException if the input contains
     * incorrect padding
@@ -144,7 +149,7 @@ public class Base64 {
     * @param offset the position within the input array at which to start
     * @param len    the number of bytes of input to decode
     * @param flags  controls certain features of the decoded output.
     *               Passing 0 to decode standard Base64.
     *               Pass {@code DEFAULT} to decode standard Base64.
     *
     * @throws IllegalArgumentException if the input contains
     * incorrect padding
@@ -362,8 +367,8 @@ public class Base64 {
     *
     * @param input  the data to encode
     * @param flags  controls certain features of the encoded output.
     *               Passing 0 results in output that adheres to RFC
     *               2045.
     *               Passing {@code DEFAULT} results in output that
     *               adheres to RFC 2045.
     */
    public static String encodeToString(byte[] input, int flags) {
        return new String(encode(input, flags));
@@ -378,8 +383,8 @@ public class Base64 {
     *               start
     * @param len    the number of bytes of input to encode
     * @param flags  controls certain features of the encoded output.
     *               Passing 0 results in output that adheres to RFC
     *               2045.
     *               Passing {@code DEFAULT} results in output that
     *               adheres to RFC 2045.
     */
    public static String encodeToString(byte[] input, int offset, int len, int flags) {
        return new String(encode(input, offset, len, flags));
@@ -391,8 +396,8 @@ public class Base64 {
     *
     * @param input  the data to encode
     * @param flags  controls certain features of the encoded output.
     *               Passing 0 results in output that adheres to RFC
     *               2045.
     *               Passing {@code DEFAULT} results in output that
     *               adheres to RFC 2045.
     */
    public static byte[] encode(byte[] input, int flags) {
        return encode(input, 0, input.length, flags);
@@ -407,8 +412,8 @@ public class Base64 {
     *               start
     * @param len    the number of bytes of input to encode
     * @param flags  controls certain features of the encoded output.
     *               Passing 0 results in output that adheres to RFC
     *               2045.
     *               Passing {@code DEFAULT} results in output that
     *               adheres to RFC 2045.
     */
    public static byte[] encode(byte[] input, int offset, int len, int flags) {
        final boolean do_padding = (flags & NO_PADDING) == 0;
@@ -494,4 +499,6 @@ public class Base64 {
        assert op == output.length;
        return output;
    }

    private Base64() { }   // don't instantiate
}