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

com.whaleal.icefrog.extra.pinyin.engine.houbbpinyin.HoubbPinyinEngine Maven / Gradle / Ivy

The newest version!
package com.whaleal.icefrog.extra.pinyin.engine.houbbpinyin;

import com.whaleal.icefrog.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 * @author wh */ 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