Class JKLocale

java.lang.Object
com.jk.core.locale.JKLocale
All Implemented Interfaces:
Serializable

public class JKLocale extends Object implements Serializable
This class represents a locale (language and regional settings)
Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final JKLocale
    Represents the Arabic locale.
    static final JKLocale
    Represents the English locale.
  • Constructor Summary

    Constructors
    Constructor
    Description
    This method initiates a new JKLocale
    JKLocale(int id, String name, String shortName)
    This method constructs a new JKLocale with the provides identifier, name and short name.
    JKLocale(int id, String name, String shortName, JKLocaleDirection direction)
    This method constructs a new JKLocale with the provides identifier, name and short name, direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    static JKLocale
    This method gets the default locale.
    This method get the locale direction.
    int
    This method gets the locale identifier (ID).
    This method gets the locale name.
    This method gets the locale short name.
    boolean
    This method checks whether this locale direction is left-to-right or not.
    static void
    setDefaultLocale(JKLocale defaultLocale)
    This method sets this locale default locale.
    void
    Sets the direction.
    void
    setId(int languageId)
    This method sets the locale identifier (ID) to the provided value.
    void
    setName(String languageName)
    This method sets the locale name to the provided value.
    void
    setShortName(String shortName)
    This method sets the locale short name to the specified value.
    Returns a string representation of the object.
    static JKLocale
    valueOf(int languageId)
    This method return the locale that corresponds to the specified language identifier (ID).
    static JKLocale
    valueOf(String localeString)
    This method returns the locale that corresponds to the specified language short name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ARABIC

      public static final JKLocale ARABIC
      Represents the Arabic locale.
    • ENGLISH

      public static final JKLocale ENGLISH
      Represents the English locale.
  • Constructor Details

    • JKLocale

      public JKLocale()
      This method initiates a new JKLocale
    • JKLocale

      public JKLocale(int id, String name, String shortName)
      This method constructs a new JKLocale with the provides identifier, name and short name.

      This method sets the Left-to-Right direction to this locale by default.

      Parameters:
      id - Specifies the locale identifier (ID).
      name - Specifies the locale name.
      shortName - Specifies the locale short name, usually made up of two letters.
    • JKLocale

      public JKLocale(int id, String name, String shortName, JKLocaleDirection direction)
      This method constructs a new JKLocale with the provides identifier, name and short name, direction.
      Parameters:
      id - Specifies the locale identifier (ID).
      name - Specifies the locale name.
      shortName - Specifies the locale short name, usually made up of two letters.
      direction - Specifies the locale language reading direction.
  • Method Details

    • valueOf

      public static JKLocale valueOf(int languageId)
      This method return the locale that corresponds to the specified language identifier (ID).

      ID: 1 (represents Arabic Locale)

      ID: 2 (represents English Locale)

      Parameters:
      languageId - Specifies the language locale identifier (ID).
      Returns:
      the locale that is associated with the provided identifier (ID).
    • valueOf

      public static JKLocale valueOf(String localeString)
      This method returns the locale that corresponds to the specified language short name.

      Arabic: ar.

      English: en.

      Parameters:
      localeString - Specifies the locale short name, usually made up of two letters.
      Returns:
      the locale that is associated with the provided short name.
    • getId

      public int getId()
      This method gets the locale identifier (ID).
      Returns:
      the locale identifier (ID).
    • setId

      public void setId(int languageId)
      This method sets the locale identifier (ID) to the provided value.
      Parameters:
      languageId - Specifies the new locale identifier (ID).
    • getName

      public String getName()
      This method gets the locale name.
      Returns:
      the locale name.
    • setName

      public void setName(String languageName)
      This method sets the locale name to the provided value.
      Parameters:
      languageName - Specifies the new locale name.
    • getShortName

      public String getShortName()
      This method gets the locale short name.
      Returns:
      the locale short name, usually made up of two letters.
    • setShortName

      public void setShortName(String shortName)
      This method sets the locale short name to the specified value.
      Parameters:
      shortName - Specifies the new locale short name, usually made up of two letters.
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      string representation of the object.
    • setDirection

      public void setDirection(JKLocaleDirection direction)
      Sets the direction.
      Parameters:
      direction - the new direction
    • getDirection

      public JKLocaleDirection getDirection()
      This method get the locale direction.
      Returns:
      the locale direction.
    • isLeftToRight

      public boolean isLeftToRight()
      This method checks whether this locale direction is left-to-right or not.
      Returns:
      true, if locale direction is left-to=right, false otherwise.
    • getDefaultLocale

      public static JKLocale getDefaultLocale()
      This method gets the default locale.
      Returns:
      the default locale.
    • setDefaultLocale

      public static void setDefaultLocale(JKLocale defaultLocale)
      This method sets this locale default locale.
      Parameters:
      defaultLocale - Specifies the new default locale.