mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -37,10 +37,8 @@ import com.github.houbb.pinyin.util.PinyinHelper;
|
||||
*/
|
||||
public class HoubbEngine implements PinyinEngine {
|
||||
|
||||
/**
|
||||
* 汉字拼音输出的格式
|
||||
*/
|
||||
PinyinStyleEnum format;
|
||||
// 汉字拼音输出的格式
|
||||
private PinyinStyleEnum format;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -40,18 +40,31 @@ import com.github.stuxuhai.jpinyin.PinyinHelper;
|
||||
public class JPinyinEngine implements PinyinEngine {
|
||||
|
||||
//设置汉子拼音输出的格式
|
||||
PinyinFormat format;
|
||||
private PinyinFormat format;
|
||||
|
||||
public JPinyinEngine(){
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public JPinyinEngine() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public JPinyinEngine(final PinyinFormat format){
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param format {@link PinyinFormat}
|
||||
*/
|
||||
public JPinyinEngine(final PinyinFormat format) {
|
||||
init(format);
|
||||
}
|
||||
|
||||
public void init(PinyinFormat format){
|
||||
if(null == format){
|
||||
/**
|
||||
* 初始化格式
|
||||
*
|
||||
* @param format 格式{@link PinyinFormat}
|
||||
*/
|
||||
public void init(PinyinFormat format) {
|
||||
if (null == format) {
|
||||
// 不加声调
|
||||
format = PinyinFormat.WITHOUT_TONE;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombi
|
||||
public class Pinyin4jEngine implements PinyinEngine {
|
||||
|
||||
//设置汉子拼音输出的格式
|
||||
HanyuPinyinOutputFormat format;
|
||||
private HanyuPinyinOutputFormat format;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
|
@@ -41,21 +41,22 @@ public class TinyPinyinEngine implements PinyinEngine {
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public TinyPinyinEngine(){
|
||||
public TinyPinyinEngine() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param config 配置
|
||||
*/
|
||||
public TinyPinyinEngine(final Pinyin.Config config){
|
||||
public TinyPinyinEngine(final Pinyin.Config config) {
|
||||
Pinyin.init(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPinyin(final char c) {
|
||||
if(!Pinyin.isChinese(c)){
|
||||
if (!Pinyin.isChinese(c)) {
|
||||
return String.valueOf(c);
|
||||
}
|
||||
return Pinyin.toPinyin(c).toLowerCase();
|
||||
|
Reference in New Issue
Block a user