@Nullable private Locale findSupportedLocale(HttpServletRequest request, List<Locale> supportedLocales) { Enumeration<Locale> requestLocales = request.getLocales(); Locale languageMatch = null; while (requestLocales.hasMoreElements()) { Locale locale = requestLocales.nextElement(); if (supportedLocales.contains(locale)) { if (languageMatch == null || languageMatch.getLanguage().equals(locale.getLanguage())) { // Full match: language + country, possibly narrowed from earlier language-only match return locale; } } else if (languageMatch == null) { // Let's try to find a language-only match as a fallback for (Locale candidate : supportedLocales) { if (!StringUtils.hasLength(candidate.getCountry()) && candidate.getLanguage().equals(locale.getLanguage())) { languageMatch = candidate; break; } } } } return languageMatch; }
public List<Locale> getLocales() { return Collections.list((request.getLocales())); }
@Override public Enumeration<Locale> getLocales() { return isNotNoOps() ? b.request.getLocales() : Collections.enumeration(b.locales); }
@Nullable private Locale findSupportedLocale(HttpServletRequest request, List<Locale> supportedLocales) { Enumeration<Locale> requestLocales = request.getLocales(); Locale languageMatch = null; while (requestLocales.hasMoreElements()) { Locale locale = requestLocales.nextElement(); if (supportedLocales.contains(locale)) { if (languageMatch == null || languageMatch.getLanguage().equals(locale.getLanguage())) { // Full match: language + country, possibly narrowed from earlier language-only match return locale; } } else if (languageMatch == null) { // Let's try to find a language-only match as a fallback for (Locale candidate : supportedLocales) { if (!StringUtils.hasLength(candidate.getCountry()) && candidate.getLanguage().equals(locale.getLanguage())) { languageMatch = candidate; break; } } } } return languageMatch; }
private static void load(HttpServletRequest request, Builder b) { Enumeration<String> e = request.getHeaderNames(); String s; while (e.hasMoreElements()) { s = e.nextElement(); b.headers.put(s, request.getHeader(s)); } synchronized (b.request) { e = request.getAttributeNames(); } while (e.hasMoreElements()) { s = e.nextElement(); b.localAttributes.put(s, attributeWithoutException(request, s)); } e = request.getParameterNames(); while (e.hasMoreElements()) { s = e.nextElement(); b.queryStrings.put(s, request.getParameterValues(s)); } b.queryString = request.getQueryString(); Enumeration<Locale> l = request.getLocales(); while (l.hasMoreElements()) { b.locale(l.nextElement()); } }
public Enumeration<Locale> getLocales() { return delegate.getLocales(); }
@Override @SuppressWarnings("unchecked") public Enumeration getLocales() { synchronized (portal) { return getRequest().getLocales(); } }
@Override public Enumeration getLocales() { return getRequest().getLocales(); }
public void visitMisc() { Map<String, Object> keyValues = createLinkedHashMap(); keyValues.put("Character Encoding", request.getCharacterEncoding()); keyValues.put("Content Length", String.valueOf(request.getContentLength())); keyValues.put("Content Type", request.getContentType()); keyValues.put("Preferred Locale", String.valueOf(request.getLocale())); keyValues.put("Supported Locales", enumToList(request.getLocales())); keyValuesComponent.visitTemplate(context, keyValues); }
public void visitMisc() { Map<String, Object> keyValues = createLinkedHashMap(); keyValues.put("Character Encoding", request.getCharacterEncoding()); keyValues.put("Content Length", String.valueOf(request.getContentLength())); keyValues.put("Content Type", request.getContentType()); keyValues.put("Preferred Locale", String.valueOf(request.getLocale())); keyValues.put("Supported Locales", enumToList(request.getLocales())); keyValuesComponent.visitTemplate(context, keyValues); }
@Override public Enumeration<Locale> getLocales() { return _request.getLocales(); }
@Override public Enumeration<Locale> getLocales() { return _request.getLocales(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Enumeration getLocales() { return parent.getLocales(); }
public Enumeration getLocales() { if (copy != null) { return copy.getLocales(); } else { ArrayList<Locale> l = new ArrayList<Locale>(); l.add(locale); return Collections.enumeration(l); } }
static void printLocales(PrintWriter pw, HttpServletRequest req) { Enumeration<Locale> en = req.getLocales(); for ( ; en.hasMoreElements() ; ) { String name = en.nextElement().toString(); pw.println("Locale: " + name); } pw.println(); }
static void printLocales(PrintWriter pw, HttpServletRequest req) { Enumeration<Locale> en = req.getLocales(); for ( ; en.hasMoreElements() ; ) { String name = en.nextElement().toString(); pw.println("Locale: " + name); } pw.println(); }
@Override @SuppressWarnings("unchecked") public ImmutableList<Locale> getLocales() { return ImmutableList.copyOf(Iterators.<Locale>forEnumeration(request.getLocales())); } }
/** {@inheritDoc} */ public Iterator getRequestLocales() { return new LocalesIterator(request.getLocales()); }
@Override @SuppressWarnings("unchecked") public Iterator<Locale> getRequestLocales() { checkHttpServletRequest(); return new EnumerationIterator(_httpServletRequest.getLocales()); }
private void initialize() { ConnectionImpl connection = ( ConnectionImpl )RWT.getUISession().getConnection(); RemoteObject remoteObject = connection.createServiceObject( "rwt.client.ClientInfo" ); remoteObject.setHandler( new InfoOperationHandler() ); HttpServletRequest request = ContextProvider.getRequest(); if( request.getHeader( "Accept-Language" ) != null ) { Enumeration<Locale> locales = request.getLocales(); this.locales = Collections.list( locales ).toArray( new Locale[ 1 ] ); } }