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

cn.hutool.extra.pinyin.engine.houbbpinyin.HoubbPinyinEngine Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.extra.pinyin.engine.houbbpinyin;

import cn.hutool.extra.pinyin.PinyinEngine;
import com.github.houbb.pinyin.constant.enums.PinyinStyleEnum;
import com.github.houbb.pinyin.util.PinyinHelper;

/**
 * 封装了 houbb Pinyin 的引擎。
 *
 * 

* houbb pinyin(https://github.com/houbb/pinyin)封装。 *

* *

* 引入: *

 * <dependency>
 *     <groupId>com.github.houbb</groupId>
 *     <artifactId>pinyin</artifactId>
 *     <version>0.2.0</version>
 * </dependency>
 * 
* * @author looly */ public class HoubbPinyinEngine implements PinyinEngine { /** * 汉字拼音输出的格式 */ PinyinStyleEnum format; /** * 构造 */ public HoubbPinyinEngine() { this(null); } /** * 构造 * * @param format 格式 */ public HoubbPinyinEngine(PinyinStyleEnum format) { init(format); } /** * 初始化 * * @param format 格式 */ public void init(PinyinStyleEnum format) { if (null == format) { format = PinyinStyleEnum.NORMAL; } this.format = format; } @Override public String getPinyin(char c) { String result; result = PinyinHelper.toPinyin(String.valueOf(c), format); return result; } @Override public String getPinyin(String str, String separator) { String result; result = PinyinHelper.toPinyin(str, format, separator); return result; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy