Class StringRanges

java.lang.Object
org.apache.juneau.StringRanges

@BeanIgnore public class StringRanges extends Object
A parsed Accept-Encoding or similar header value.

The returned ranges are sorted such that the most acceptable value is available at ordinal position '0', and the least acceptable at position n-1.

RFC2616 Specification
The Accept-Encoding request-header field is similar to Accept, but restricts the content-codings (section 3.5) that are acceptable in the response.

Accept-Encoding = "Accept-Encoding" ":" 1#( codings [ ";" "q" "=" qvalue ] ) codings = ( content-coding | "*" )

Examples of its use are:

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

See Also:
  • Field Details

    • EMPTY

      public static final StringRanges EMPTY
      Represents an empty string ranges object.
  • Constructor Details

    • StringRanges

      public StringRanges(String value)
      Constructor.
      Parameters:
      value - The string range header value.
    • StringRanges

      public StringRanges(StringRange... value)
      Constructor.
      Parameters:
      value - The string range header value.
    • StringRanges

      Constructor.
      Parameters:
      e - The parsed string range header value.
  • Method Details

    • of

      public static StringRanges of(String value)
      Returns a parsed string range header value.
      Parameters:
      value - The raw header value.
      Returns:
      A parsed header value.
    • of

      public static StringRanges of(StringRange... value)
      Returns a parsed string range header value.
      Parameters:
      value - The raw header value.
      Returns:
      A parsed header value.
    • 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.
    • 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.
    • toList

      public List<StringRange> toList()
      Returns the string ranges that make up this object.
      Returns:
      The string ranges that make up this object.
    • forEachRange

      Performs an action on the string ranges that make up this object.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • toString

      public String toString()
      Overrides:
      toString in class Object