Class LocalePropertyProviderGenerator

java.lang.Object
com.google.gwt.i18n.linker.LocalePropertyProviderGenerator
All Implemented Interfaces:
PropertyProviderGenerator

public class LocalePropertyProviderGenerator extends Object implements PropertyProviderGenerator
Generates a property provider implementation for the "locale" property.
  • Field Details

  • Constructor Details

    • LocalePropertyProviderGenerator

      public LocalePropertyProviderGenerator()
  • Method Details

    • isTrue

      protected static boolean isTrue(String value)
      Return true when the supplied value represents a true/yes/on value.
      Parameters:
      value -
      Returns:
      true if the string represents true/yes/on
    • generate

      public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException
      Description copied from interface: PropertyProviderGenerator
      Generate a property provider.
      Specified by:
      generate in interface PropertyProviderGenerator
      Parameters:
      logger - TreeLogger
      possibleValues - the possible values of this property
      fallback - the fallback value for this property, or null
      configProperties - the configuration properties for this module
      Returns:
      the JS source of the property provider (the complete body of a JS function taking no arguments, including open/close braces), or null to use the default implementation in the property-provider tag
      Throws:
      UnableToCompleteException - after logging the message if processing is unable to continue
    • generateCookieLookup

      protected void generateCookieLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String cookieName) throws UnableToCompleteException
      Generate JS code that looks up the locale value from a cookie.
      Parameters:
      logger - logger to use
      body -
      cookieName -
      Throws:
      UnableToCompleteException
    • generateInheritanceLookup

      protected void generateInheritanceLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
      Generate JS code that takes the value of the "locale" variable and finds parent locales until the value is a supported locale or the default locale.
      Parameters:
      logger - logger to use
      body -
      Throws:
      UnableToCompleteException
    • generateMetaLookup

      protected void generateMetaLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
      Generate JS code to fetch the locale from a meta property.
      Parameters:
      logger - logger to use
      body -
      Throws:
      UnableToCompleteException
    • generateQueryParamLookup

      protected void generateQueryParamLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String queryParam) throws UnableToCompleteException
      Generate JS code to get the locale from a query parameter.
      Parameters:
      logger - logger to use
      body - where to append JS output
      queryParam - the query parameter to use
      Throws:
      UnableToCompleteException
    • generateUserAgentLookup

      protected void generateUserAgentLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
      Generate JS code to fetch the locale from the user agent's compile-time locale.
      Parameters:
      logger - logger to use
      body -
      Throws:
      UnableToCompleteException
    • validateCookieName

      protected boolean validateCookieName(String cookieName)
      Validate that a name is a valid cookie name.
      Parameters:
      cookieName -
      Returns:
      true if cookieName is an acceptable cookie name
    • validateQueryParam

      protected boolean validateQueryParam(String queryParam)
      Validate that a value is a valid query parameter name.
      Parameters:
      queryParam -
      Returns:
      true if queryParam is a valid query parameter name.