Class Range

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Range extends ProxyInstance

Represents a byte range as used in the Range header.

If end is non-negative, then start and end represent the bounds of of the range, counting from 0. (Eg, the first 500 bytes would be represented as start = 0 and end = 499.)

If end is -1 and start is non-negative, then this represents a range starting at start and ending with the last byte of the requested resource body. (Eg, all but the first 500 bytes would be start = 500, and end = -1.)

If end is -1 and start is negative, then it represents a "suffix range", referring to the last -start bytes of the resource body. (Eg, the last 500 bytes would be start = -500 and end = -1.)

  • Constructor Details

    • Range

      public Range(MemorySegment address)
      Create a Range proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Range

      public Range(Arena arena)
      Allocate a new Range.
      Parameters:
      arena - to control the memory allocation scope
    • Range

      public Range()
      Allocate a new Range. The memory is allocated with Arena.ofAuto().
    • Range

      public Range(long start, long end, Arena arena)
      Allocate a new Range with the fields set to the provided values.
      Parameters:
      start - value for the field start
      end - value for the field end
      arena - to control the memory allocation scope
    • Range

      public Range(long start, long end)
      Allocate a new Range with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      start - value for the field start
      end - value for the field end
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readStart

      public long readStart()
      Read the value of the field start.
      Returns:
      The value of the field start
    • writeStart

      public void writeStart(long start)
      Write a value in the field start.
      Parameters:
      start - The new value for the field start
    • readEnd

      public long readEnd()
      Read the value of the field end.
      Returns:
      The value of the field end
    • writeEnd

      public void writeEnd(long end)
      Write a value in the field end.
      Parameters:
      end - The new value for the field end