Class StringRange

java.lang.Object
org.apache.juneau.StringRange

@BeanIgnore public class StringRange extends Object
Represents a single value in a comma-delimited header value that optionally contains a quality metric for comparison and extension parameters.

Similar in concept to MediaRanges except instead of media types (e.g. "text/json"), it's a simple type (e.g. "iso-8601").

An example of a type range is a value in an Accept-Encoding header.

See Also:
  • Constructor Details

    • StringRange

      public StringRange(String value)
      Constructor.
      Parameters:
      value - The raw string range string.
      A value of null gets interpreted as matching anything (e.g. "*").
    • StringRange

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

    • getName

      public String getName()
      Returns the name of this string range.

      This is the primary value minus the quality or other parameters.

      Returns:
      The name of this string range.
    • getQValue

      public Float getQValue()
      Returns the 'q' (quality) value for this type, as described in Section 3.9 of RFC2616.

      The quality value is a float between 0.0 (unacceptable) and 1.0 (most acceptable).

      If 'q' value doesn't make sense for the context (e.g. this range was extracted from a "content-*" header, as opposed to "accept-*" header, its value will always be "1".

      Returns:
      The 'q' value for this type, never null.
    • getExtensions

      Returns the optional set of custom extensions defined for this type.

      Values are lowercase and never null.

      Returns:
      The optional list of extensions, never null.
    • forEachExtension

      Performs an action on the optional set of custom extensions defined for this type.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • equals

      public boolean equals(Object o)
      Returns true if the specified object is also a StringRange, and has the same qValue, type, parameters, and extensions.
      Overrides:
      equals in class Object
      Returns:
      true if object is equivalent.
    • hashCode

      public int hashCode()
      Returns a hash based on this instance's media-type.
      Overrides:
      hashCode in class Object
      Returns:
      A hash based on this instance's media-type.
    • match

      public int match(String name)
      Performs a match of this string range against the specified name.
      Parameters:
      name - The name being compared against.
      Returns:
      0 = no match, 100 = perfect match, 50 = meta-match.
    • toString

      public String toString()
      Overrides:
      toString in class Object