/** * See parseLocale(String, String) for details. */ public static Locale parseLocale(String locale) { return parseLocale(locale, null); }
/** * See parseLocale(String, String) for details. */ public static Locale parseLocale(String locale) { return parseLocale(locale, null); }
static Locale getLocale(PageContext pageContext, String name) { Locale loc = null; Object obj = Config.find(pageContext, name); if (obj != null) { if (obj instanceof Locale) { loc = (Locale) obj; } else { loc = LocaleUtil.parseLocale((String) obj); } } return loc; }
/** * Handles Locales that can be passed to tags as instances of String or Locale. * If the parameter is an instance of Locale, it is simply returned. * If the parameter is a String and is not empty, then it is parsed to a Locale * using {@link LocaleUtil#parseLocale(String)}. * Otherwise null will be returned. * * @param stringOrLocale locale represented as an instance of Locale or as a String * @return the locale represented by the parameter, or null if the parameter is undefined */ public static Locale parseLocaleAttributeValue(Object stringOrLocale) { if (stringOrLocale instanceof Locale) { return (Locale) stringOrLocale; } else if (stringOrLocale instanceof String) { String string = (String) stringOrLocale; if (string.length() == 0) { return null; } else { return parseLocale(string.trim()); } } else { return null; } }
static Locale getLocale(PageContext pageContext, String name) { Locale loc = null; Object obj = Config.find(pageContext, name); if (obj != null) { if (obj instanceof Locale) { loc = (Locale) obj; } else { loc = LocaleUtil.parseLocale((String) obj); } } return loc; }
/** * Handles Locales that can be passed to tags as instances of String or Locale. * If the parameter is an instance of Locale, it is simply returned. * If the parameter is a String and is not empty, then it is parsed to a Locale * using {@link LocaleUtil#parseLocale(String)}. * Otherwise null will be returned. * * @param stringOrLocale locale represented as an instance of Locale or as a String * @return the locale represented by the parameter, or null if the parameter is undefined */ public static Locale parseLocaleAttributeValue(Object stringOrLocale) { if (stringOrLocale instanceof Locale) { return (Locale) stringOrLocale; } else if (stringOrLocale instanceof String) { String string = (String) stringOrLocale; if (string.length() == 0) { return null; } else { return parseLocale(string.trim()); } } else { return null; } }
@Override public int doEndTag() throws JspException { Locale locale; if (value instanceof Locale) { locale = (Locale) value; } else if (value instanceof String && !"".equals(((String)value).trim())) { locale = LocaleUtil.parseLocale((String) value, variant); } else { locale = Locale.getDefault(); } Config.set(pageContext, Config.FMT_LOCALE, locale, scope); setResponseLocale(pageContext, locale); return EVAL_PAGE; }
@Override public int doEndTag() throws JspException { Locale locale; if (value instanceof Locale) { locale = (Locale) value; } else if (value instanceof String && !"".equals(((String)value).trim())) { locale = LocaleUtil.parseLocale((String) value, variant); } else { locale = Locale.getDefault(); } Config.set(pageContext, Config.FMT_LOCALE, locale, scope); setResponseLocale(pageContext, locale); return EVAL_PAGE; }