Class EnglishLanguageHandler

java.lang.Object
io.github.zazalng.handler.EnglishLanguageHandler
All Implemented Interfaces:
LanguageHandler

public class EnglishLanguageHandler extends Object implements LanguageHandler
English language implementation of LanguageHandler.

This handler converts numeric amounts to English textual representation using standard English conventions. It implements the complete conversion logic previously found in EnglishConvertHandler.

English Number Formatting Rules

This converter implements standard English number-to-word conventions:

  • Hyphens for compound numbers: Twenty-Five, Ninety-Nine, etc.
  • Position words: Hundred, Thousand, Million
  • Capitalization: Each word starts with capital letter
  • Spacing: Position words separated by spaces
  • Zero handling: Single 0 = "Zero", portions of 0 = omitted

Unit Words

  • "Baht" - Currency unit
  • "Satang" - Fractional unit
  • "Only" - Exact indicator (used when satang is zero)

Examples


 handler.convert(ThaiBaht.of(new BigDecimal("100.00"), config));
 // Output: "One Hundred Baht Only"

 handler.convert(ThaiBaht.of(new BigDecimal("1234.56"), config));
 // Output: "One Thousand Two Hundred Thirty-Four Baht Fifty-Six Satang"
 
Since:
2.0.0
Author:
Zazalng
See Also:
  • Constructor Details

    • EnglishLanguageHandler

      public EnglishLanguageHandler()
  • Method Details

    • convert

      public String convert(ThaiBaht baht)
      Description copied from interface: LanguageHandler
      Converts the amount in the given ThaiBaht instance to language-specific text.

      The implementation must respect the configuration options from baht.getConfig(), including unit word inclusion, custom format templates, and negative prefix settings.

      Specified by:
      convert in interface LanguageHandler
      Parameters:
      baht - the ThaiBaht instance containing amount and configuration, never null
      Returns:
      the language-specific textual representation of the amount, never null
    • getLanguageCode

      public String getLanguageCode()
      Description copied from interface: LanguageHandler
      Returns the language code identifier for this handler.

      This is typically a two or three-letter ISO 639 code (e.g., "th" for Thai, "en" for English).

      Specified by:
      getLanguageCode in interface LanguageHandler
      Returns:
      the language code, never null or empty
    • getLanguageName

      public String getLanguageName()
      Description copied from interface: LanguageHandler
      Returns the human-readable name of this language.

      This is typically used for display and identification purposes.

      Specified by:
      getLanguageName in interface LanguageHandler
      Returns:
      the language name (e.g., "Thai", "English"), never null or empty
    • getUnitWord

      public String getUnitWord()
      Description copied from interface: LanguageHandler
      Returns the currency unit word for the integer (baht) part.

      Examples:

      • Thai: "บาท" (Baht)
      • English: "Baht"
      • Laotian: "ກີບ" (Kip)
      Specified by:
      getUnitWord in interface LanguageHandler
      Returns:
      the unit word, never null or empty
    • getExactWord

      public String getExactWord()
      Description copied from interface: LanguageHandler
      Returns the exact/only indicator word displayed when satang (fractional part) is zero.

      Examples:

      • Thai: "ถ้วน" (Exact/Full)
      • English: "Only"
      Specified by:
      getExactWord in interface LanguageHandler
      Returns:
      the exact indicator word, never null or empty
    • getSatangWord

      public String getSatangWord()
      Description copied from interface: LanguageHandler
      Returns the satang (fractional currency unit) word.

      Examples:

      • Thai: "สตางค์" (Satang)
      • English: "Satang"
      Specified by:
      getSatangWord in interface LanguageHandler
      Returns:
      the satang unit word, never null or empty
    • getNegativePrefix

      public String getNegativePrefix()
      Description copied from interface: LanguageHandler
      Returns the default prefix applied to negative amounts.

      This prefix is used when the amount is negative, unless explicitly overridden via ThaiBahtConfig.Builder.setPrefix(String).

      Examples:

      • Thai: "ลบ" (Thai minus symbol)
      • English: "Minus"
      Specified by:
      getNegativePrefix in interface LanguageHandler
      Returns:
      the negative prefix, never null or empty