- All Superinterfaces:
org.miaixz.bus.core.Provider,Serializable
- All Known Implementing Classes:
Bopomofo4JProvider,HoubbProvider,JPinyinProvider,Pinyin4JProvider,TinyPinyinProvider
public interface PinyinProvider
extends org.miaixz.bus.core.Provider
Pinyin engine interface. Implementations of this interface provide specific Pinyin conversion functionalities.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptiondefault chargetFirstLetter(char c) Converts a single character to its Pinyin first letter.default StringgetFirstLetter(String str, String separator) Converts a string to its Pinyin first letters, with a custom separator.default StringgetPinyin(char c) Converts a single character to its Pinyin.getPinyin(char c, boolean tone) Converts a single character to its Pinyin, with an option to retain tone marks.default StringRetrieves the complete Pinyin for a given string.Retrieves the complete Pinyin for a given string, with an option to retain tone marks.default Objecttype()
-
Method Details
-
getPinyin
Converts a single character to its Pinyin. If the character is a Chinese character, its uppercase Pinyin is returned; otherwise, the character itself is returned as a string.- Parameters:
c- The character to convert.- Returns:
- The Pinyin of the Chinese character, or the character itself if not Chinese.
-
getPinyin
Converts a single character to its Pinyin, with an option to retain tone marks. If the character is a Chinese character, its Pinyin is returned; otherwise, the character itself is returned as a string.- Parameters:
c- The character to convert.tone-trueto retain tone marks in the Pinyin,falseotherwise.- Returns:
- The Pinyin of the Chinese character, or the character itself if not Chinese.
-
getPinyin
Retrieves the complete Pinyin for a given string. Non-Chinese characters remain as is.- Parameters:
text- The input string.separator- The separator to use between each Pinyin character.- Returns:
- The Pinyin representation of the string.
-
getPinyin
Retrieves the complete Pinyin for a given string, with an option to retain tone marks. Non-Chinese characters remain as is.- Parameters:
text- The input string.separator- The separator to use between each Pinyin character.tone-trueto retain tone marks in the Pinyin,falseotherwise.- Returns:
- The Pinyin representation of the string.
-
getFirstLetter
default char getFirstLetter(char c) Converts a single character to its Pinyin first letter. If the character is a Chinese character, its Pinyin's first letter is returned; otherwise, the character itself is returned.- Parameters:
c- The character to convert.- Returns:
- The first letter of the Pinyin for the Chinese character, or the character itself if not Chinese.
-
getFirstLetter
Converts a string to its Pinyin first letters, with a custom separator. Non-Chinese characters remain as is.- Parameters:
str- The input string.separator- The separator to use between each first letter.- Returns:
- The string composed of the first letters of Pinyin for Chinese characters, and original characters for others.
-
type
- Specified by:
typein interfaceorg.miaixz.bus.core.Provider
-