<commit_before>package com.eaglesakura.util;

import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringUtil {

    static {
        base64Converter = new Base64Converter() {
            /**
             * base64 encode/decode
             */
            private Class base64Class = null;

            /**
             * base64 encode
             */
            private Method base64Encode = null;

            /**
             * base64 decode
             */
            private Method base64Decode = null;

            private int flags;

            static final int URL_SAFE = 8;

            static final int NO_WRAP = 2;

            static final int NO_PADDING = 1;

            static final int NO_CLOSE = 16;

            Base64Converter init() {
                // init for Android
                try {
                    base64Class = Class.forName("android.util.Base64");
                    base64Encode = base64Class.getMethod("encodeToString", byte[].class);
                    base64Decode = base64Class.getMethod("decode", byte[].class);
                    flags = NO_CLOSE | NO_PADDING | NO_WRAP | URL_SAFE;
                    return this;
                } catch (Exception e) {
                }

                // init for Apache
                try {
                    base64Class = Class.forName("org.apache.commons.codec.binary.Base64");
                    base64Encode = base64Class.getMethod("encodeBase64", byte[].class);
                    base64Decode = base64Class.getMethod("decodeBase64", byte[].class);
                    flags = 0;
                    return this;
                } catch (Exception e) {
                }
                throw new IllegalStateException();
            }

            @Override
            public String encode(byte[] buffer) {
                try {
                    return (String) base64Encode.invoke(base64Class, buffer, flags /* Base64.Default */);<commit_msg>正常にbase64 encode/decodeできない問題を修正<commit_after>package com.eaglesakura.util;

import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringUtil {

    static {
        base64Converter = new Base64Converter() {
            /**
             * base64 encode/decode
             */
            private Class base64Class = null;

            /**
             * base64 encode
             */
            private Method base64Encode = null;

            /**
             * base64 decode
             */
            private Method base64Decode = null;

            private int flags;

            static final int URL_SAFE = 8;

            static final int NO_WRAP = 2;

            static final int NO_PADDING = 1;

            static final int NO_CLOSE = 16;

            Base64Converter init() {
                // init for Android
                try {
                    base64Class = Class.forName("android.util.Base64");
                    base64Encode = base64Class.getMethod("encodeToString", byte[].class, int.class);
                    base64Decode = base64Class.getMethod("decode", String.class, int.class);
                    flags = NO_CLOSE | NO_PADDING | NO_WRAP | URL_SAFE;
                    return this;
                } catch (Exception e) {
                }

                // init for Apache
                try {
                    base64Class = Class.forName("org.apache.commons.codec.binary.Base64");
                    base64Encode = base64Class.getMethod("encodeBase64", byte[].class, int.class);
                    base64Decode = base64Class.getMethod("decodeBase64", String.class, int.class);
                    flags = 0;
                    return this;
                } catch (Exception e) {
                }
                throw new IllegalStateException();
            }

            @Override
            public String encode(byte[] buffer) {
                try {
                    return (String) base64Encode.invoke(base64Class, buffer, flags /* Base64.Default */);
{'fraction_non_alphanumeric': 0.0865035134480252, 'fraction_numerical': 0.028592197722316453, 'mean_word_length': 1.3629078420148826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4549333', 'n_tokens_mistral': 1116, 'n_tokens_neox': 986, 'n_words': 237}