Class LangTag

java.lang.Object
org.apache.jena.riot.web.LangTag

public class LangTag extends Object
Language tags: support for parsing and canonicalization of case. Grandfathered forms ("i-") are left untouched. Unsupported or syntactically illegal forms are handled in canonicalization by doing nothing.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Index of all extensions
    static final int
    Index of the language part
    static final int
    Index of the region part
    static final int
    Index of the script part
    static final int
    Index of the variant part
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Canonicalize with the rules of RFC 4646, or RFC5646 without replacement of preferred form.
    static String
    canonical(String[] parts)
    Canonicalize with the rules of RFC 4646 "In this format, all non-initial two-letter subtags are uppercase, all non-initial four-letter subtags are titlecase, and all other subtags are lowercase." In addition, leave extensions unchanged.
    static boolean
    check(String languageTag)
    Validate - basic syntax check for a language tags: [a-zA-Z]+ ('-'[a-zA-Z0-9]+)*
    static String[]
    parse(String languageTag)
    Parse a langtag string and return it's parts in canonical case.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • idxLanguage

      public static final int idxLanguage
      Index of the language part
      See Also:
    • idxScript

      public static final int idxScript
      Index of the script part
      See Also:
    • idxRegion

      public static final int idxRegion
      Index of the region part
      See Also:
    • idxVariant

      public static final int idxVariant
      Index of the variant part
      See Also:
    • idxExtension

      public static final int idxExtension
      Index of all extensions
      See Also:
  • Method Details

    • check

      public static boolean check(String languageTag)
      Validate - basic syntax check for a language tags: [a-zA-Z]+ ('-'[a-zA-Z0-9]+)*
    • parse

      public static String[] parse(String languageTag)
      Parse a langtag string and return it's parts in canonical case. See constants for the array contents. Parts not present cause a null in the return array.
      Returns:
      Langtag parts, or null if the input string does not parse as a lang tag.
    • canonical

      public static String canonical(String str)
      Canonicalize with the rules of RFC 4646, or RFC5646 without replacement of preferred form.
    • canonical

      public static String canonical(String[] parts)
      Canonicalize with the rules of RFC 4646 "In this format, all non-initial two-letter subtags are uppercase, all non-initial four-letter subtags are titlecase, and all other subtags are lowercase." In addition, leave extensions unchanged.

      This is the same as RFC5646 without replacement of preferred form or consulting the registry.