All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mygreen.cellformatter.callback.ZenkakuNumberCallback Maven / Gradle / Ivy

There is a newer version: 0.12
Show newest version
package com.github.mygreen.cellformatter.callback;

import java.util.Locale;

/**
 * 半角数字を全角数字に変換する。
 * 
 * @version 0.5
 * @author T.TSUCHIE
 *
 */
public class ZenkakuNumberCallback extends JapaneseCallback {
    
    private static final String[][] MAP = {
        {"0", "0"},
        {"1", "1"},
        {"2", "2"},
        {"3", "3"},
        {"4", "4"},
        {"5", "5"},
        {"6", "6"},
        {"7", "7"},
        {"8", "8"},
        {"9", "9"},
    };
    
    public static ZenkakuNumberCallback create() {
        return new ZenkakuNumberCallback();
    }
    
    @Override
    public String call(final Object data, final String value, final Locale locale) {
        
        String str = value;
        for(String[] item : MAP) {
            str = str.replaceAll(item[0], item[1]);
        }
        return str;
    }
}