Class AcceptType

java.lang.Object
org.apache.olingo.commons.api.format.AcceptType

public final class AcceptType extends Object
Internally used AcceptType for OData library. See RFC 7231, chapter 5.3.2:
 Accept = #( media-range [ accept-params ] )
 media-range = ( "*/*"
 / ( type "/" "*" )
 / ( type "/" subtype )
 ) *( OWS ";" OWS parameter )
 accept-params = weight *( accept-ext )
 accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]
 weight = OWS ";" OWS "q=" qvalue
 qvalue = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
 
Once created an AcceptType is IMMUTABLE.
  • Method Details

    • create

      public static List<AcceptType> create(String acceptTypes)
      Creates a list of AcceptType objects based on given input string.
      Parameters:
      acceptTypes - accept types, comma-separated, as specified for the HTTP header Accept
      Returns:
      a list of AcceptType objects
      Throws:
      IllegalArgumentException - if input string is not parseable
    • fromContentType

      public static List<AcceptType> fromContentType(ContentType contentType)
      Creates a list of AcceptType objects based on given content type.
      Parameters:
      contentType - the content type
      Returns:
      an immutable one-element list of AcceptType objects that matches only the given content type
    • getType

      public String getType()
    • getSubtype

      public String getSubtype()
    • getParameters

      public Map<String,String> getParameters()
    • getParameter

      public String getParameter(String name)
    • getQuality

      public Float getQuality()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • matches

      public boolean matches(ContentType contentType)

      Determines whether this accept type matches a given content type.

      A match is defined as fulfilling all of the following conditions:

      • the type must be '*' or equal to the content-type's type,
      • the subtype must be '*' or equal to the content-type's subtype,
      • all parameters must have the same value as in the content-type's parameter map.

      Parameters:
      contentType - content type against which is matched
      Returns:
      whether this accept type matches the given content type