public class LocalePropertyProviderGenerator extends Object implements PropertyProviderGenerator
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
COOKIE_PATTERN |
static String |
LOCALE_COOKIE |
static String |
LOCALE_QUERYPARAM |
static String |
LOCALE_SEARCHORDER |
static String |
LOCALE_USEMETA |
static String |
LOCALE_USERAGENT |
protected static Pattern |
QUERYPARAM_PATTERN |
Constructor and Description |
---|
LocalePropertyProviderGenerator() |
Modifier and Type | Method and Description |
---|---|
String |
generate(TreeLogger logger,
SortedSet<String> possibleValues,
String fallback,
SortedSet<ConfigurationProperty> configProperties)
Generate a property provider.
|
protected void |
generateCookieLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body,
String cookieName)
Generate JS code that looks up the locale value from a cookie.
|
protected void |
generateInheritanceLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body)
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.
|
protected void |
generateMetaLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body)
Generate JS code to fetch the locale from a meta property.
|
protected void |
generateQueryParamLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body,
String queryParam)
Generate JS code to get the locale from a query parameter.
|
protected void |
generateUserAgentLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body)
Generate JS code to fetch the locale from the user agent's compile-time
locale.
|
protected static boolean |
isTrue(String value)
Return true when the supplied value represents a true/yes/on value.
|
protected boolean |
validateCookieName(String cookieName)
Validate that a name is a valid cookie name.
|
protected boolean |
validateQueryParam(String queryParam)
Validate that a value is a valid query parameter name.
|
public static final String LOCALE_QUERYPARAM
public static final String LOCALE_COOKIE
public static final String LOCALE_SEARCHORDER
public static final String LOCALE_USEMETA
public static final String LOCALE_USERAGENT
protected static final Pattern COOKIE_PATTERN
protected static final Pattern QUERYPARAM_PATTERN
protected static boolean isTrue(String value)
value
- public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException
PropertyProviderGenerator
generate
in interface PropertyProviderGenerator
logger
- TreeLoggerpossibleValues
- the possible values of this propertyfallback
- the fallback value for this property, or nullconfigProperties
- the configuration properties for this moduleUnableToCompleteException
- after logging the message if processing
is unable to continueprotected void generateCookieLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String cookieName) throws UnableToCompleteException
logger
- logger to usebody
- cookieName
- UnableToCompleteException
protected void generateInheritanceLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
logger
- logger to usebody
- UnableToCompleteException
protected void generateMetaLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
logger
- logger to usebody
- UnableToCompleteException
protected void generateQueryParamLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String queryParam) throws UnableToCompleteException
logger
- logger to usebody
- where to append JS outputqueryParam
- the query parameter to useUnableToCompleteException
protected void generateUserAgentLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException
logger
- logger to usebody
- UnableToCompleteException
protected boolean validateCookieName(String cookieName)
cookieName
- protected boolean validateQueryParam(String queryParam)
queryParam
- Copyright © 2018. All rights reserved.