Class ContentRange


  • public class ContentRange
    extends java.lang.Object
    Represents a parsed Content-Range HTTP header value as defined by RFC 9110.
    • Constructor Summary

      Constructors 
      Constructor Description
      ContentRange​(java.lang.String units, long start, long end, long length)
      Creates a new ContentRange with the specified values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getEnd()
      Returns the end position of the content range.
      long getLength()
      Returns the total length of the resource.
      long getStart()
      Returns the start position of the content range.
      java.lang.String getUnits()
      Returns the range units (e.g., "bytes") in lower case.
      boolean isValid()
      Validates this content range according to RFC 9110 section 14.4.
      static ContentRange parse​(java.io.StringReader input)
      Parses a Content-Range header from an HTTP header.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ContentRange

        public ContentRange​(java.lang.String units,
                            long start,
                            long end,
                            long length)
        Creates a new ContentRange with the specified values.
        Parameters:
        units - the range units (e.g., "bytes"), lowercased
        start - the start position of the range
        end - the end position of the range
        length - the total length of the resource
    • Method Detail

      • getUnits

        public java.lang.String getUnits()
        Returns the range units (e.g., "bytes") in lower case.
        Returns:
        the range units, or null if not set
      • getStart

        public long getStart()
        Returns the start position of the content range.
        Returns:
        the start position
      • getEnd

        public long getEnd()
        Returns the end position of the content range.
        Returns:
        the end position
      • getLength

        public long getLength()
        Returns the total length of the resource.
        Returns:
        the total resource length
      • parse

        public static ContentRange parse​(java.io.StringReader input)
                                  throws java.io.IOException
        Parses a Content-Range header from an HTTP header.
        Parameters:
        input - a reader over the header text
        Returns:
        the range parsed from the input, or null if not valid
        Throws:
        java.io.IOException - if there was a problem reading the input
      • isValid

        public boolean isValid()
        Validates this content range according to RFC 9110 section 14.4.
        Returns:
        true if start >= 0, end >= start, and length > end