Module bus.extra

Class PinyinFactory

java.lang.Object
org.miaixz.bus.extra.pinyin.PinyinFactory

public class PinyinFactory extends Object
Simple Pinyin engine factory that automatically creates the corresponding Pinyin engine object based on the Pinyin library JARs introduced by the user. It uses the Simple Factory pattern.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • PinyinFactory

      public PinyinFactory()
  • Method Details

    • get

      public static PinyinProvider get()
      Retrieves a singleton instance of PinyinProvider. The first available Pinyin provider found via SPI will be used.
      Returns:
      A singleton instance of PinyinProvider.
    • create

      public static PinyinProvider create()
      Creates a new PinyinProvider instance. This method returns a new engine instance each time it is called.
      Returns:
      A new PinyinProvider instance.
    • create

      public static PinyinProvider create(String name) throws org.miaixz.bus.core.lang.exception.InternalException
      Creates a custom Pinyin engine by name.
      Parameters:
      name - The name of the engine (case-insensitive), e.g., `Bopomofo4j`, `Houbb`, `JPinyin`, `Pinyin4j`, `TinyPinyin`.
      Returns:
      The PinyinProvider instance corresponding to the given name.
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if no engine with the specified name is found.