Module bus.extra

Interface PinyinProvider

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 Type
    Method
    Description
    default char
    Converts a single character to its Pinyin first letter.
    default String
    getFirstLetter(String str, String separator)
    Converts a string to its Pinyin first letters, with a custom separator.
    default String
    getPinyin(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 String
    getPinyin(String text, String separator)
    Retrieves the complete Pinyin for a given string.
    getPinyin(String text, String separator, boolean tone)
    Retrieves the complete Pinyin for a given string, with an option to retain tone marks.
    default Object
     
  • Method Details

    • getPinyin

      default String getPinyin(char c)
      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

      String getPinyin(char c, boolean tone)
      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 - true to retain tone marks in the Pinyin, false otherwise.
      Returns:
      The Pinyin of the Chinese character, or the character itself if not Chinese.
    • getPinyin

      default String getPinyin(String text, String separator)
      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

      String getPinyin(String text, String separator, boolean tone)
      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 - true to retain tone marks in the Pinyin, false otherwise.
      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

      default String getFirstLetter(String str, String separator)
      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

      default Object type()
      Specified by:
      type in interface org.miaixz.bus.core.Provider