/*
 * このソースコードは blanco Frameworkによって自動生成されています。
 */
package blanco.sample.stringconverter;

/**
 * 全角カタカナ→全角ひらがなの文字列変換のサンプル。blancoStringConverterの実装には影響しません。
 */
public class SampleZenKatakana2HiraganaStringConverter {
    /**
     * 文字列置換定義。
     */
    public static final String[][] STRING_CONVERT_DEF = new String[][] {new String[] { "ヴ", "う゛" }/* No.1 説明:濁音を先に定義します。 */, new String[] { "ァ", "ぁ" }/* No.2 */, new String[] { "ア", "あ" }/* No.3 */, new String[] { "ィ", "ぃ" }/* No.4 */, new String[] { "イ", "い" }/* No.5 */, new String[] { "ゥ", "ぅ" }/* No.6 */, new String[] { "ウ", "う" }/* No.7 */, new String[] { "ェ", "ぇ" }/* No.8 */, new String[] { "エ", "え" }/* No.9 */, new String[] { "ォ", "ぉ" }/* No.10 */, new String[] { "オ", "お" }/* No.11 */, new String[] { "カ", "か" }/* No.12 */, new String[] { "ガ", "が" }/* No.13 */, new String[] { "キ", "き" }/* No.14 */, new String[] { "ギ", "ぎ" }/* No.15 */, new String[] { "ク", "く" }/* No.16 */, new String[] { "グ", "ぐ" }/* No.17 */, new String[] { "ケ", "け" }/* No.18 */, new String[] { "ゲ", "げ" }/* No.19 */, new String[] { "コ", "こ" }/* No.20 */, new String[] { "ゴ", "ご" }/* No.21 */, new String[] { "サ", "さ" }/* No.22 */, new String[] { "ザ", "ざ" }/* No.23 */, new String[] { "シ", "し" }/* No.24 */, new String[] { "ジ", "じ" }/* No.25 */, new String[] { "ス", "す" }/* No.26 */, new String[] { "ズ", "ず" }/* No.27 */, new String[] { "セ", "せ" }/* No.28 */, new String[] { "ゼ", "ぜ" }/* No.29 */, new String[] { "ソ", "そ" }/* No.30 */, new String[] { "ゾ", "ぞ" }/* No.31 */, new String[] { "タ", "た" }/* No.32 */, new String[] { "ダ", "だ" }/* No.33 */, new String[] { "チ", "ち" }/* No.34 */, new String[] { "ヂ", "ぢ" }/* No.35 */, new String[] { "ッ", "っ" }/* No.36 */, new String[] { "ツ", "つ" }/* No.37 */, new String[] { "ヅ", "づ" }/* No.38 */, new String[] { "テ", "て" }/* No.39 */, new String[] { "デ", "で" }/* No.40 */, new String[] { "ト", "と" }/* No.41 */, new String[] { "ド", "ど" }/* No.42 */, new String[] { "ナ", "な" }/* No.43 */, new String[] { "ニ", "に" }/* No.44 */, new String[] { "ヌ", "ぬ" }/* No.45 */, new String[] { "ネ", "ね" }/* No.46 */, new String[] { "ノ", "の" }/* No.47 */, new String[] { "ハ", "は" }/* No.48 */, new String[] { "バ", "ば" }/* No.49 */, new String[] { "パ", "ぱ" }/* No.50 */, new String[] { "ヒ", "ひ" }/* No.51 */, new String[] { "ビ", "び" }/* No.52 */, new String[] { "ピ", "ぴ" }/* No.53 */, new String[] { "フ", "ふ" }/* No.54 */, new String[] { "ブ", "ぶ" }/* No.55 */, new String[] { "プ", "ぷ" }/* No.56 */, new String[] { "ヘ", "へ" }/* No.57 */, new String[] { "ベ", "べ" }/* No.58 */, new String[] { "ペ", "ぺ" }/* No.59 */, new String[] { "ホ", "ほ" }/* No.60 */, new String[] { "ボ", "ぼ" }/* No.61 */, new String[] { "ポ", "ぽ" }/* No.62 */, new String[] { "マ", "ま" }/* No.63 */, new String[] { "ミ", "み" }/* No.64 */, new String[] { "ム", "む" }/* No.65 */, new String[] { "メ", "め" }/* No.66 */, new String[] { "モ", "も" }/* No.67 */, new String[] { "ャ", "ゃ" }/* No.68 */, new String[] { "ヤ", "や" }/* No.69 */, new String[] { "ュ", "ゅ" }/* No.70 */, new String[] { "ユ", "ゆ" }/* No.71 */, new String[] { "ョ", "ょ" }/* No.72 */, new String[] { "ヨ", "よ" }/* No.73 */, new String[] { "ラ", "ら" }/* No.74 */, new String[] { "リ", "り" }/* No.75 */, new String[] { "ル", "る" }/* No.76 */, new String[] { "レ", "れ" }/* No.77 */, new String[] { "ロ", "ろ" }/* No.78 */, new String[] { "ヮ", "ゎ" }/* No.79 */, new String[] { "ワ", "わ" }/* No.80 */, new String[] { "ヰ", "ゐ" }/* No.81 */, new String[] { "ヱ", "ゑ" }/* No.82 */, new String[] { "ヲ", "を" }/* No.83 */, new String[] { "ン", "ん" }/* No.84 */, new String[] { "ヵ", "か" }/* No.87 説明:全角ひらがなに相当するものが無いため、大きい文字に強制的にマッピング。 */, new String[] { "ヶ", "け" }/* No.88 説明:全角ひらがなに相当するものが無いため、大きい文字に強制的にマッピング。 */ };

    /**
     * 文字列変換定義に従い、文字列を変換します。
     *
     * @param argCheck 変換対象の文字列。
     * @return 文字列変換定義にしたがって変換された文字列。変換定義にひとつも合致しない場合には元の文字列が戻ります。
     */
    public String convert(final String argCheck) {
        if (argCheck == null) {
            throw new IllegalArgumentException("メソッド[convert]のパラメータ[argCheck]にnullが与えられました。しかし、このパラメータにnullを与えることはできません。");
        }

        String wrkString = "";
        for (int index = 0; index < argCheck.length(); ) {
            final String look = argCheck.substring(index);
            boolean isFound = false;
            for (int indexDef = 0; indexDef < STRING_CONVERT_DEF.length; indexDef++) {
                if (look.startsWith(STRING_CONVERT_DEF[indexDef][0])) {
                    wrkString += STRING_CONVERT_DEF[indexDef][1];
                    index += STRING_CONVERT_DEF[indexDef][0].length();
                    isFound = true;
                    break;
                }
            }
            if (!isFound) {
                wrkString += argCheck.charAt(index);
                index = index + 1;
            }
        }

        return wrkString;
    }
}
