/** * Get the name of the remote user from the REMOTE_USER header. * * @return The name of the remote user */ public String getRemoteUser() { return getHeader("REMOTE_USER"); }
/** * Get the name of the remote user from the REMOTE_USER header. * * @return The name of the remote user */ public String getRemoteUser() { return getHeader("REMOTE_USER"); }
/** * Get the given header as an int. * * @param name * The header name * @return The header value or -1 if header not found * @throws NumberFormatException * If the header is not formatted correctly */ public int getIntHeader(final String name) { String value = getHeader(name); if (value == null) { return -1; } return Integer.valueOf(value).intValue(); }
/** * Get the given header as an int. * * @param name * The header name * @return The header value or -1 if header not found * @throws NumberFormatException * If the header is not formatted correctly */ public int getIntHeader(final String name) { String value = getHeader(name); if (value == null) { return -1; } return Integer.valueOf(value).intValue(); }
/** * Get the given header as a date. * * @param name * The header name * @return The date, or -1 if header not found * @throws IllegalArgumentException * If the header cannot be converted */ public long getDateHeader(final String name) throws IllegalArgumentException { String value = getHeader(name); if (value == null) { return -1; } DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); try { return df.parse(value).getTime(); } catch (ParseException e) { throw new IllegalArgumentException("Can't convert header to date " + name + ": " + value); } }
/** * Get the given header as a date. * * @param name * The header name * @return The date, or -1 if header not found * @throws IllegalArgumentException * If the header cannot be converted */ public long getDateHeader(final String name) throws IllegalArgumentException { String value = getHeader(name); if (value == null) { return -1; } DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); try { return df.parse(value).getTime(); } catch (ParseException e) { throw new IllegalArgumentException("Can't convert header to date " + name + ": " + value); } }
/** * Return all the accepted locales. This implementation always returns just one. * * @return The locales */ public Enumeration<Locale> getLocales() { List<Locale> list = new ArrayList<Locale>(); final String header = getHeader("Accept-Language"); if (header != null) { final String[] locales = header.split(","); for (String value : locales) { Locale locale = getLocale(value); if (locale != null) { list.add(locale); } } } if (list.size() == 0) { list.add(Locale.getDefault()); } return Collections.enumeration(list); }
final String header = getHeader("Accept-Language"); if (header == null)