Class BasicStringRangesHeader

java.lang.Object
org.apache.juneau.http.classic.header.BasicHeader
org.apache.juneau.http.classic.header.BasicStringRangesHeader
All Implemented Interfaces:
Serializable, Header, NameValuePair
Direct Known Subclasses:
AcceptCharset, AcceptEncoding, AcceptLanguage, ContentDisposition, TE

Category of headers that consist of simple comma-delimited lists of strings with q-values.

Example

Accept-Encoding: compress;q=0.5, gzip;q=1.0

See Also:
  • Constructor Details

  • Method Details

    • of

      public static BasicStringRangesHeader of(String name, String value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Must be parsable by StringRanges.of(String).
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicStringRangesHeader of(String name, StringRanges value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicStringRangesHeader of(String name, Supplier<StringRanges> value)
      Static creator with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      name - The header name.
      value - The supplier of the header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • asStringRanges

      Returns the header value as a StringRanges wrapped in an Optional.
      Returns:
      The header value as a StringRanges wrapped in an Optional. Never null.
    • getRange

      public StringRange getRange(int index)
      Returns the MediaRange at the specified index.
      Parameters:
      index - The index position of the media range.
      Returns:
      The MediaRange at the specified index or null if the index is out of range.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicHeader
    • match

      public int match(List<String> names)
      Given a list of media types, returns the best match for this string range header.

      Note that fuzzy matching is allowed on the media types where the string range header may contain additional subtype parts.
      For example, given identical q-values and an string range value of "text/json+activity", the media type "text/json" will match if "text/json+activity" or "text/activity+json" isn't found.
      The purpose for this is to allow serializers to match when artifacts such as id properties are present in the header.

      See ActivityPub / Retrieving Objects

      Parameters:
      names - The names to match against.
      Returns:
      The index into the array of the best match, or -1 if no suitable matches could be found.
    • orElse

      Return the value if present, otherwise return other.

      This is a shortened form for calling asArray().orElse(other).

      Parameters:
      other - The value to be returned if there is no value present, can be null.
      Returns:
      The value, if present, otherwise other.
    • toStringRanges

      Returns the header value as a StringRanges.
      Returns:
      The header value as a StringRanges, or null if the header has no value.