diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinEngine.java index f4cb7f32e..74e40bb3e 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinEngine.java @@ -21,15 +21,6 @@ public interface PinyinEngine { */ String getPinyin(char c); - /** - * 如果c为汉字,则返回大写拼音;如果c不是汉字,则返回String.valueOf(c) - * - * @param c 任意字符,汉字返回拼音,非汉字原样返回 - * @param tone 是否返回声调 - * @return 汉字返回拼音,非汉字原样返回 - */ - String getPinyin(char c, boolean tone); - /** * 获取字符串对应的完整拼音,非中文返回原字符 * @@ -39,17 +30,6 @@ public interface PinyinEngine { */ String getPinyin(String str, String separator); - /** - * 获取字符串对应的完整拼音,非中文返回原字符 - * - * @param str 字符串 - * @param separator 拼音之间的分隔符 - * @param tone 是否返回声调 - * @return 拼音 - */ - String getPinyin(String str, String separator,boolean tone); - - /** * 将输入字符串转为拼音首字母,其它字符原样返回 * diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinUtil.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinUtil.java index d6ac1497f..e1f618ac1 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinUtil.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/PinyinUtil.java @@ -31,17 +31,6 @@ public class PinyinUtil { return getEngine().getPinyin(c); } - /** - * 如果c为汉字,则返回大写拼音;如果c不是汉字,则返回String.valueOf(c) - * - * @param c 任意字符,汉字返回拼音,非汉字原样返回 - * @param tone 是否返回声调 - * @return 汉字返回拼音,非汉字原样返回 - */ - public static String getPinyin(final char c, boolean tone) { - return getEngine().getPinyin(c,tone); - } - /** * 将输入字符串转为拼音,每个字之间的拼音使用空格分隔 * @@ -52,17 +41,6 @@ public class PinyinUtil { return getPinyin(str, StrUtil.SPACE); } - /** - * 将输入字符串转为拼音,每个字之间的拼音使用空格分隔 - * - * @param str 任意字符,汉字返回拼音,非汉字原样返回 - * @param tone 是否返回声调 - * @return 汉字返回拼音,非汉字原样返回 - */ - public static String getPinyin(final String str, boolean tone) { - return getPinyin(str, StrUtil.SPACE, tone); - } - /** * 将输入字符串转为拼音,以字符为单位插入分隔符 * @@ -74,18 +52,6 @@ public class PinyinUtil { return getEngine().getPinyin(str, separator); } - /** - * 将输入字符串转为拼音,以字符为单位插入分隔符 - * - * @param str 任意字符,汉字返回拼音,非汉字原样返回 - * @param separator 每个字拼音之间的分隔符 - * @param tone 是否返回声调 - * @return 汉字返回拼音,非汉字原样返回 - */ - public static String getPinyin(final String str, final String separator, boolean tone) { - return getEngine().getPinyin(str, separator, tone); - } - /** * 将输入字符串转为拼音首字母,其它字符原样返回 * diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/bopomofo4j/Bopomofo4jEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/bopomofo4j/Bopomofo4jEngine.java index 7980704c7..433f5d30b 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/bopomofo4j/Bopomofo4jEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/bopomofo4j/Bopomofo4jEngine.java @@ -36,26 +36,8 @@ public class Bopomofo4jEngine implements PinyinEngine { return Bopomofo4j.pinyin(String.valueOf(c), ToneType.WITHOUT_TONE, false, false, StrUtil.EMPTY); } - @Override - public String getPinyin(char c, boolean tone) { - if (tone) { - return Bopomofo4j.pinyin(String.valueOf(c), ToneType.WITH_VOWEL_TONE, false, false, StrUtil.EMPTY); - }else{ - return getPinyin(c); - } - } - @Override public String getPinyin(String str, String separator) { return Bopomofo4j.pinyin(str, ToneType.WITHOUT_TONE, false, false, separator); } - - @Override - public String getPinyin(String str, String separator, boolean tone) { - if (tone) { - return Bopomofo4j.pinyin(str, ToneType.WITH_VOWEL_TONE, false, false, separator); - }else{ - return getPinyin(str, separator); - } - } } diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/houbbpinyin/HoubbPinyinEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/houbbpinyin/HoubbPinyinEngine.java index 275036a59..323ef1718 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/houbbpinyin/HoubbPinyinEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/houbbpinyin/HoubbPinyinEngine.java @@ -65,34 +65,10 @@ public class HoubbPinyinEngine implements PinyinEngine { return result; } - @Override - public String getPinyin(char c, boolean tone) { - try{ - if(tone){ - format = PinyinStyleEnum.DEFAULT; - } - return getPinyin(c); - }finally { - format = PinyinStyleEnum.NORMAL; - } - } - @Override public String getPinyin(String str, String separator) { String result; result = PinyinHelper.toPinyin(str, format, separator); return result; } - - @Override - public String getPinyin(String str, String separator, boolean tone) { - try{ - if(tone){ - format = PinyinStyleEnum.DEFAULT; - } - return getPinyin(str,separator); - }finally { - format = PinyinStyleEnum.NORMAL; - } - } } diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/jpinyin/JPinyinEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/jpinyin/JPinyinEngine.java index 61ba6dd32..c0a247ad2 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/jpinyin/JPinyinEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/jpinyin/JPinyinEngine.java @@ -53,18 +53,6 @@ public class JPinyinEngine implements PinyinEngine { return ArrayUtil.isEmpty(results) ? String.valueOf(c) : results[0]; } - @Override - public String getPinyin(char c, boolean tone) { - try{ - if (tone) { - format = PinyinFormat.WITH_TONE_MARK; - } - return getPinyin(c); - }finally { - format = PinyinFormat.WITHOUT_TONE; - } - } - @Override public String getPinyin(String str, String separator) { try { @@ -73,17 +61,4 @@ public class JPinyinEngine implements PinyinEngine { throw new cn.hutool.extra.pinyin.PinyinException(e); } } - - @Override - public String getPinyin(String str, String separator, boolean tone) { - try{ - if (tone) { - format = PinyinFormat.WITH_TONE_MARK; - } - return getPinyin(str,separator); - }finally { - format = PinyinFormat.WITHOUT_TONE; - } - } - } diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/pinyin4j/Pinyin4jEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/pinyin4j/Pinyin4jEngine.java index 1a4a70f6a..241d12bdc 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/pinyin4j/Pinyin4jEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/pinyin4j/Pinyin4jEngine.java @@ -82,21 +82,6 @@ public class Pinyin4jEngine implements PinyinEngine { return result; } - @Override - public String getPinyin(char c, boolean tone) { - try { - if(tone){ - //增加声调 - format.setToneType(HanyuPinyinToneType.WITH_TONE_MARK); - format.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE); - } - return getPinyin(c); - }finally { - format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); - format.setVCharType(HanyuPinyinVCharType.WITH_V); - } - } - @Override public String getPinyin(String str, String separator) { final StrBuilder result = StrUtil.strBuilder(); @@ -122,19 +107,4 @@ public class Pinyin4jEngine implements PinyinEngine { return result.toString(); } - - @Override - public String getPinyin(String str, String separator, boolean tone) { - try { - if(tone){ - //增加声调 - format.setToneType(HanyuPinyinToneType.WITH_TONE_MARK); - format.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE); - } - return getPinyin(str, separator); - }finally { - format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); - format.setVCharType(HanyuPinyinVCharType.WITH_V); - } - } } diff --git a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/tinypinyin/TinyPinyinEngine.java b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/tinypinyin/TinyPinyinEngine.java index 8da4ea8de..0ac8b0c52 100644 --- a/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/tinypinyin/TinyPinyinEngine.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/pinyin/engine/tinypinyin/TinyPinyinEngine.java @@ -50,20 +50,10 @@ public class TinyPinyinEngine implements PinyinEngine { return Pinyin.toPinyin(c).toLowerCase(); } - @Override - public String getPinyin(char c, boolean tone) { - return getPinyin(c); - } - @Override public String getPinyin(String str, String separator) { final String pinyin = Pinyin.toPinyin(str, separator); return StrUtil.isEmpty(pinyin) ? pinyin : pinyin.toLowerCase(); } - @Override - public String getPinyin(String str, String separator, boolean tone) { - return getPinyin(str, separator); - } - }