public class LocalePropertyProviderGenerator extends java.lang.Object implements PropertyProviderGenerator
Modifier and Type | Field and Description |
---|---|
protected static java.util.regex.Pattern |
COOKIE_PATTERN |
static java.lang.String |
LOCALE_COOKIE |
static java.lang.String |
LOCALE_QUERYPARAM |
static java.lang.String |
LOCALE_SEARCHORDER |
static java.lang.String |
LOCALE_USEMETA |
static java.lang.String |
LOCALE_USERAGENT |
protected static java.util.regex.Pattern |
QUERYPARAM_PATTERN |
Constructor and Description |
---|
LocalePropertyProviderGenerator() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generate(TreeLogger logger,
java.util.SortedSet<java.lang.String> possibleValues,
java.lang.String fallback,
java.util.SortedSet<ConfigurationProperty> configProperties)
Generate a property provider.
|
protected void |
generateCookieLookup(TreeLogger logger,
com.google.gwt.user.rebind.SourceWriter body,
java.lang.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,
java.lang.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(java.lang.String value)
Return true when the supplied value represents a true/yes/on value.
|
protected boolean |
validateCookieName(java.lang.String cookieName)
Validate that a name is a valid cookie name.
|
protected boolean |
validateQueryParam(java.lang.String queryParam)
Validate that a value is a valid query parameter name.
|
public static final java.lang.String LOCALE_QUERYPARAM
public static final java.lang.String LOCALE_COOKIE
public static final java.lang.String LOCALE_SEARCHORDER
public static final java.lang.String LOCALE_USEMETA
public static final java.lang.String LOCALE_USERAGENT
protected static final java.util.regex.Pattern COOKIE_PATTERN
protected static final java.util.regex.Pattern QUERYPARAM_PATTERN
protected static boolean isTrue(java.lang.String value)
value
- public java.lang.String generate(TreeLogger logger, java.util.SortedSet<java.lang.String> possibleValues, java.lang.String fallback, java.util.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, java.lang.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, java.lang.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(java.lang.String cookieName)
cookieName
- protected boolean validateQueryParam(java.lang.String queryParam)
queryParam
-