From e24b1bb85ec6445cf6fcac189f8d411acbefd095 Mon Sep 17 00:00:00 2001 From: ucchyocean Date: Tue, 23 Apr 2013 01:22:25 +0900 Subject: [PATCH] LunaChat v1.1.0 : refactored. --- pom.xml | 4 + .../github/ucchyocean/lc/KanaConverter.java | 113 +++++++++--------- .../github/ucchyocean/lc/PlayerListener.java | 4 +- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/pom.xml b/pom.xml index 24dd9c3..e2c72c9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,6 +4,10 @@ LunaChat 1.1.0 + + UTF-8 + + ${project.artifactId} diff --git a/src/main/java/com/github/ucchyocean/lc/KanaConverter.java b/src/main/java/com/github/ucchyocean/lc/KanaConverter.java index d5ac48b..7403351 100644 --- a/src/main/java/com/github/ucchyocean/lc/KanaConverter.java +++ b/src/main/java/com/github/ucchyocean/lc/KanaConverter.java @@ -5,67 +5,66 @@ */ package com.github.ucchyocean.lc; +import java.util.HashMap; + /** * @author ucchy * ローマ字からかな文字へ変換するクラス */ public class KanaConverter { - private static final String[][] TABLE = { - { "", "あ","い","う","え","お" }, - { "k", "か","き","く","け","こ" }, - { "s", "さ","し","す","せ","そ" }, - { "t", "た","ち","つ","て","と" }, - { "n", "な","に","ぬ","ね","の" }, - { "h", "は","ひ","ふ","へ","ほ" }, - { "m", "ま","み","む","め","も" }, - { "y", "や","い","ゆ","いぇ","よ" }, - { "r", "ら","り","る","れ","ろ" }, - { "w", "わ","うぃ","う","うぇ","を" }, - - { "g", "が","ぎ","ぐ","げ","ご" }, - { "z", "ざ","じ","ず","ぜ","ぞ" }, - { "j", "じゃ","じ","じゅ","じぇ","じょ" }, - { "d", "だ","ぢ","づ","で","ど" }, - { "b", "ば","び","ぶ","べ","ぼ" }, - { "p", "ぱ","ぴ","ぷ","ぺ","ぽ" }, - { "gy", "ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ" }, - { "zy", "じゃ","じぃ","じゅ","じぇ","じょ" }, - { "jy", "じゃ","じぃ","じゅ","じぇ","じょ" }, - { "dy", "ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ" }, - { "by", "びゃ","びぃ","びゅ","びぇ","びょ" }, - { "py", "ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ" }, - - { "l", "ぁ","ぃ","ぅ","ぇ","ぉ" }, - { "v", "ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ" }, - { "sh", "しゃ","し","しゅ","しぇ","しょ" }, - { "sy", "しゃ","し","しゅ","しぇ","しょ" }, - { "ch", "ちゃ","ち","ちゅ","ちぇ","ちょ" }, - { "cy", "ちゃ","ち","ちゅ","ちぇ","ちょ" }, - - { "f", "ふぁ","ふぃ","ふ","ふぇ","ふぉ" }, - { "q", "くぁ","くぃ","く","くぇ","くぉ" }, - { "ky", "きゃ","きぃ","きゅ","きぇ","きょ" }, - { "ty", "ちゃ","ちぃ","ちゅ","ちぇ","ちょ" }, - { "ny", "にゃ","にぃ","にゅ","にぇ","にょ" }, - { "hy", "ひゃ","ひぃ","ひゅ","ひぇ","ひょ" }, - { "my", "みゃ","みぃ","みゅ","みぇ","みょ" }, - { "ry", "りゃ","りぃ","りゅ","りぇ","りょ" }, - { "ly", "ゃ","ぃ","ゅ","ぇ","ょ" }, - { "lt", "た","ち","っ","て","と" }, - { "xy", "ゃ","ぃ","ゅ","ぇ","ょ" }, - { "xt", "た","ち","っ","て","と" }, - { "x", "ぁ","ぃ","ぅ","ぇ","ぉ" }, + private static final HashMap TABLE; + static { + TABLE = new HashMap(); + TABLE.put( "", new String[]{"あ","い","う","え","お"}); + TABLE.put( "k", new String[]{"か","き","く","け","こ"}); + TABLE.put( "s", new String[]{"さ","し","す","せ","そ"}); + TABLE.put( "t", new String[]{"た","ち","つ","て","と"}); + TABLE.put( "n", new String[]{"な","に","ぬ","ね","の"}); + TABLE.put( "h", new String[]{"は","ひ","ふ","へ","ほ"}); + TABLE.put( "m", new String[]{"ま","み","む","め","も"}); + TABLE.put( "y", new String[]{"や","い","ゆ","いぇ","よ"}); + TABLE.put( "r", new String[]{"ら","り","る","れ","ろ"}); + TABLE.put( "w", new String[]{"わ","うぃ","う","うぇ","を"}); + TABLE.put( "g", new String[]{"が","ぎ","ぐ","げ","ご"}); + TABLE.put( "z", new String[]{"ざ","じ","ず","ぜ","ぞ"}); + TABLE.put( "j", new String[]{"じゃ","じ","じゅ","じぇ","じょ"}); + TABLE.put( "d", new String[]{"だ","ぢ","づ","で","ど"}); + TABLE.put( "b", new String[]{"ば","び","ぶ","べ","ぼ"}); + TABLE.put( "p", new String[]{"ぱ","ぴ","ぷ","ぺ","ぽ"}); + TABLE.put("gy", new String[]{"ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ"}); + TABLE.put("zy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"}); + TABLE.put("jy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"}); + TABLE.put("dy", new String[]{"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ"}); + TABLE.put("by", new String[]{"びゃ","びぃ","びゅ","びぇ","びょ"}); + TABLE.put("py", new String[]{"ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ"}); + TABLE.put( "l", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"}); + TABLE.put( "v", new String[]{"ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ"}); + TABLE.put("sh", new String[]{"しゃ","し","しゅ","しぇ","しょ"}); + TABLE.put("sy", new String[]{"しゃ","し","しゅ","しぇ","しょ"}); + TABLE.put("ch", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"}); + TABLE.put("cy", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"}); + TABLE.put( "f", new String[]{"ふぁ","ふぃ","ふ","ふぇ","ふぉ"}); + TABLE.put( "q", new String[]{"くぁ","くぃ","く","くぇ","くぉ"}); + TABLE.put("ky", new String[]{"きゃ","きぃ","きゅ","きぇ","きょ"}); + TABLE.put("ty", new String[]{"ちゃ","ちぃ","ちゅ","ちぇ","ちょ"}); + TABLE.put("ny", new String[]{"にゃ","にぃ","にゅ","にぇ","にょ"}); + TABLE.put("hy", new String[]{"ひゃ","ひぃ","ひゅ","ひぇ","ひょ"}); + TABLE.put("my", new String[]{"みゃ","みぃ","みゅ","みぇ","みょ"}); + TABLE.put("ry", new String[]{"りゃ","りぃ","りゅ","りぇ","りょ"}); + TABLE.put("ly", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"}); + TABLE.put("lt", new String[]{"た","ち","っ","て","と"}); + TABLE.put("xy", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"}); + TABLE.put("xt", new String[]{"た","ち","っ","て","と"}); + TABLE.put( "x", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"}); }; + + private static String getKanaFromTable(String s, int n) { - private static String R2K(String s, int n) { - - for ( int i=0; i