ContentRange Class
- java.
lang. Object - com.
azure. ai. contentunderstanding. models. ContentRange
- com.
public final class ContentRange
Represents a range of content to analyze. Use this type with the com.azure.ai.contentunderstanding.ContentUnderstandingClient#beginAnalyzeBinary(String, com.azure.core.util.BinaryData, ContentRange, String, ProcessingLocation) overload for a self-documenting API.
For documents, ranges use 1-based page numbers (e.g., "1-3", "5", "9-"). For audio/video, ranges use integer milliseconds (e.g., "0-5000", "5000-"). Multiple ranges can be combined with commas (e.g., "1-3,5,9-").
Example usage:
// Document pages
ContentRange range = ContentRange.pages(1, 3); // "1-3"
ContentRange single = ContentRange.page(5); // "5"
ContentRange openEnd = ContentRange.pagesFrom(9); // "9-"
// Audio/video time ranges
ContentRange time = ContentRange.timeRange(
Duration.ZERO, Duration.ofMillis(5000)); // "0-5000"
ContentRange timeOpen = ContentRange.timeRangeFrom(
Duration.ofMillis(5000)); // "5000-"
// Combine multiple ranges
ContentRange combined = ContentRange.combine(
ContentRange.pages(1, 3),
ContentRange.page(5),
ContentRange.pagesFrom(9)); // "1-3,5,9-"
// Or construct from a raw string
ContentRange raw = new ContentRange("1-3,5,9-");
Constructor Summary
| Constructor | Description |
|---|---|
| ContentRange(String value) |
Initializes a new instance of ContentRange from a raw range string. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Content |
combine(ContentRange[] ranges)
Combines multiple ContentRange values into a single comma-separated range. |
| boolean | equals(Object obj) |
| int | hashCode() |
|
static
Content |
page(int pageNumber)
Creates a ContentRange for a single document page (1-based). |
|
static
Content |
pages(int start, int end)
Creates a ContentRange for a contiguous range of document pages (1-based, inclusive). |
|
static
Content |
pagesFrom(int startPage)
Creates a ContentRange for all document pages from a starting page to the end (1-based). |
|
static
Content |
timeRange(Duration start, Duration end)
Creates a ContentRange for a time range using Duration values (for audio/video content). |
|
static
Content |
timeRangeFrom(Duration start)
Creates a ContentRange for all content from a starting time to the end using a Duration value. |
| String |
toString()
Returns the wire-format string representation of this range. |
Methods inherited from java.lang.Object
Constructor Details
ContentRange
public ContentRange(String value)
Initializes a new instance of ContentRange from a raw range string.
Parameters:
Method Details
combine
public static ContentRange combine(ContentRange[] ranges)
Combines multiple ContentRange values into a single comma-separated range.
Parameters:
Returns:
"1-3,5,9-".equals
public boolean equals(Object obj)
Overrides:
ContentRange.equals(Object obj)Parameters:
hashCode
public int hashCode()
Overrides:
ContentRange.hashCode()page
public static ContentRange page(int pageNumber)
Creates a ContentRange for a single document page (1-based).
Parameters:
Returns:
"5".pages
public static ContentRange pages(int start, int end)
Creates a ContentRange for a contiguous range of document pages (1-based, inclusive).
Parameters:
Returns:
"1-3".pagesFrom
public static ContentRange pagesFrom(int startPage)
Creates a ContentRange for all document pages from a starting page to the end (1-based).
Parameters:
Returns:
"9-".timeRange
public static ContentRange timeRange(Duration start, Duration end)
Creates a ContentRange for a time range using Duration values (for audio/video content).
Parameters:
Returns:
"0-5000".timeRangeFrom
public static ContentRange timeRangeFrom(Duration start)
Creates a ContentRange for all content from a starting time to the end using a Duration value.
Parameters:
Returns:
"5000-".toString
public String toString()
Returns the wire-format string representation of this range.
Overrides:
ContentRange.toString()Returns: