LanguageCodeValidator (Apache OpenNLP :: API 3.0.0-M4 API)
Description: declaration: package: opennlp.tools.util, class: LanguageCodeValidator

Package opennlp.tools.util

# Class LanguageCodeValidator

java.lang.Object
opennlp.tools.util.LanguageCodeValidator

public final class LanguageCodeValidator extends Object
Validates language codes against ISO 639 standards.

Accepts:

- ISO 639-1 two-letter language codes (e.g., `"en"`, `"de"`)
- ISO 639-2/3 three-letter language codes (e.g., `"eng"`, `"deu"`)
- The special code `"x-unspecified"` used internally by OpenNLP

Valid codes are derived from `Locale.availableLocales()` plus additional ISO 639-2 bibliographic codes and `"und"` (undetermined).

See Also:
  - ISO 639-3

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `isValid(String languageCode)`
  Checks whether the given language code is a valid ISO 639 code.
  `static void`
  `validateLanguageCode(String languageCode)`
  Validates the given language code and throws an `IllegalArgumentException` if it is not a recognized ISO 639 language code.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isValid

    public static boolean isValid(String languageCode)
    Checks whether the given language code is a valid ISO 639 code.
    Parameters:
      `languageCode` - The language code to check. Must not be `null`.
    Returns:
      `true` if the code is valid, `false` otherwise.
    Throws:
      `IllegalArgumentException` - if `languageCode` is `null`.

  - ### validateLanguageCode

    public static void validateLanguageCode(String languageCode)
    Validates the given language code and throws an `IllegalArgumentException` if it is not a recognized ISO 639 language code.
    Parameters:
      `languageCode` - The language code to validate. Must not be `null`.
    Throws:
      `IllegalArgumentException` - if the code is not a valid ISO 639 language code or is `null`.