Freigeben über


ContentRange Class

  • java.lang.Object
    • com.azure.ai.contentunderstanding.models.ContentRange

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 ContentRange combine(ContentRange[] ranges)

Combines multiple ContentRange values into a single comma-separated range.

boolean equals(Object obj)
int hashCode()
static ContentRange page(int pageNumber)

Creates a ContentRange for a single document page (1-based).

static ContentRange pages(int start, int end)

Creates a ContentRange for a contiguous range of document pages (1-based, inclusive).

static ContentRange pagesFrom(int startPage)

Creates a ContentRange for all document pages from a starting page to the end (1-based).

static ContentRange timeRange(Duration start, Duration end)

Creates a ContentRange for a time range using Duration values (for audio/video content).

static ContentRange 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:

value - The range string value.

Method Details

combine

public static ContentRange combine(ContentRange[] ranges)

Combines multiple ContentRange values into a single comma-separated range.

Parameters:

ranges - The ranges to combine.

Returns:

A ContentRange representing the combined ranges, e.g. "1-3,5,9-".

equals

public boolean equals(Object obj)

Overrides:

ContentRange.equals(Object obj)

Parameters:

obj

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:

pageNumber - The 1-based page number.

Returns:

A ContentRange representing the single page, e.g. "5".

pages

public static ContentRange pages(int start, int end)

Creates a ContentRange for a contiguous range of document pages (1-based, inclusive).

Parameters:

start - The 1-based start page number (inclusive).
end - The 1-based end page number (inclusive).

Returns:

A ContentRange representing the page range, e.g. "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:

startPage - The 1-based start page number (inclusive).

Returns:

A ContentRange representing the open-ended page range, e.g. "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:

start - The start time (inclusive).
end - The end time (inclusive).

Returns:

A ContentRange representing the time range, e.g. "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:

start - The start time (inclusive).

Returns:

A ContentRange representing the open-ended time range, e.g. "5000-".

toString

public String toString()

Returns the wire-format string representation of this range.

Overrides:

ContentRange.toString()

Returns:

The range string.

Applies to