org.restlet.data

## Class Range

- java.lang.Object
- - org.restlet.data.Range

    public class Range
    extends java.lang.Object

Describes a range of bytes.

Author:
  Jerome Louvel

### Field Summary

Fields
`static long` `INDEX_FIRST` Index for the first byte of an entity.
`static long` `INDEX_LAST` Index for the last byte of an entity.
`static long` `SIZE_MAX` Maximum size available from the index.

### Constructor Summary

Constructors
Constructor and Description
`Range()` Default constructor defining a range starting on the first byte and with a maximum size, i.e.
`Range(long size)` Constructor defining a range starting on the first byte and with the given size.
`Range(long index, long size)` Constructor.

### Method Summary

Methods
`boolean` `equals(java.lang.Object object)`
`long` `getIndex()` Returns the index from which to start the range.
`long` `getSize()` Returns the size of the range in number of bytes.
`boolean` `isIncluded(long position, long totalSize)` Indicates if the given index is included in the range.
`void` `setIndex(long index)` Sets the index from which to start the range.
`void` `setSize(long size)` Sets the size of the range in number of bytes.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### INDEX_FIRST

    public static final long INDEX_FIRST

Index for the first byte of an entity.

See Also:
  Constant Field Values

#### INDEX_LAST

    public static final long INDEX_LAST

Index for the last byte of an entity.

See Also:
  Constant Field Values

#### SIZE_MAX

    public static final long SIZE_MAX

Maximum size available from the index.

See Also:
  Constant Field Values

### Constructor Detail

#### Range

    public Range()

Default constructor defining a range starting on the first byte and with a maximum size, i.e. covering the whole entity.

#### Range

    public Range(long size)

Constructor defining a range starting on the first byte and with the given size.

Parameters:
  `size` - Size of the range in number of bytes.

#### Range

    public Range(long index,
         long size)

Constructor.

Parameters:
  `index` - Index from which to start the range
  `size` - Size of the range in number of bytes.

### Method Detail

#### equals

    public boolean equals(java.lang.Object object)

Overrides:
  `equals` in class `java.lang.Object`

#### getIndex

    public long getIndex()

Returns the index from which to start the range. If the index is superior or equal to zero, the index will define the start of the range. If its value is -1L (-1), then it defines the end of the range. The default value is `INDEX_FIRST` (0), starting at the first byte.

Returns:
  The index from which to start the range.

#### getSize

    public long getSize()

Returns the size of the range in number of bytes. If the size is the maximum available from the index, then use the -1L constant.

Returns:
  The size of the range in number of bytes.

#### isIncluded

    public boolean isIncluded(long position,
                     long totalSize)

Indicates if the given index is included in the range.

Parameters:
  `position` - The position to test.
  `totalSize` -
Returns:
  True if the given index is included in the range, false otherwise.

#### setIndex

    public void setIndex(long index)

Sets the index from which to start the range. If the index is superior or equal to zero, the index will define the start of the range. If its value is -1L (-1), then it defines the end of the range. The default value is `INDEX_FIRST` (0), starting at the first byte

Parameters:
  `index` - The index from which to start the range.

#### setSize

    public void setSize(long size)

Sets the size of the range in number of bytes. If the size is the maximum available from the index, then use the -1L constant.

Parameters:
  `size` - The size of the range in number of bytes.