Class HeaderHelper

java.lang.Object
org.exoplatform.services.rest.impl.header.HeaderHelper

public final class HeaderHelper extends Object
Version:
$Id: $
Author:
Andrey Parfonov
  • Field Details

  • Method Details

    • createAcceptedMediaTypeList

      public static List<AcceptMediaType> createAcceptedMediaTypeList(String header)
      Create sorted by quality value accepted media type list.
      Parameters:
      header - source header string
      Returns:
      List of AcceptMediaType
    • createAcceptedLanguageList

      public static List<AcceptLanguage> createAcceptedLanguageList(String header)
      Create sorted by quality value accepted language list.
      Parameters:
      header - source header string
      Returns:
      List of AcceptLanguage
    • createAcceptedCharsetList

      public static List<AcceptToken> createAcceptedCharsetList(String header)
      Create sorted by quality value 'accept-character' list.
      Parameters:
      header - source header string
      Returns:
      List of accept charset tokens
    • createAcceptedEncodingList

      public static List<AcceptToken> createAcceptedEncodingList(String header)
      Create sorted by quality value 'accept-encoding' list.
      Parameters:
      header - source header string
      Returns:
      List of accept encoding tokens
    • parseCookies

      public static List<javax.ws.rs.core.Cookie> parseCookies(String cookie)
      Parse cookie header string and create collection of cookie from it.
      Parameters:
      cookie - the cookie string.
      Returns:
      collection of Cookie.
    • getDateFormats

      public static List<SimpleDateFormat> getDateFormats()
      Returns:
      list of allowed date formats
    • parseDateHeader

      public static Date parseDateHeader(String header)
      Parse date header. Will try to found appropriated format for given date header. Format can be one of see HTTP/1.1 documentation
      Parameters:
      header - source date header
      Returns:
      parsed Date
    • getContentLengthLong

      public static long getContentLengthLong(javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders)
      Parameters:
      httpHeaders - HTTP headers
      Returns:
      parsed content-length or null if content-length header is not specified
    • getHeaderAsString

      public static String getHeaderAsString(Object o)
      Create string representation of Java Object for adding to response. Method use Object.toString().
      Parameters:
      o - HTTP header as Java type.
      Returns:
      string representation of supplied type
    • convertToString

      public static String convertToString(Collection<String> collection)
      Convert Collection<String> to single String, where values separated by ','. Useful for getting source string of HTTP header for next processing quality value of header tokens.
      Parameters:
      collection - the source list
      Returns:
      String result