{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

OffsetMapping

public interface OffsetMapping


Provides bidirectional offset mapping between original and transformed text.

Summary

Nested types

public static class OffsetMapping.Companion

Public methods

abstract int

Convert offset in original text into the offset in transformed text.

abstract int

Convert offset in transformed text into the offset in original text.

Public methods

originalToTransformed

abstract int originalToTransformed(int offset)

Convert offset in original text into the offset in transformed text.

This function must be a monotonically non-decreasing function. In other words, if a cursor advances in the original text, the cursor in the transformed text must advance or stay there.

Parameters
int offset

offset in original text.

Returns
int

offset in transformed text

transformedToOriginal

abstract int transformedToOriginal(int offset)

Convert offset in transformed text into the offset in original text.

This function must be a monotonically non-decreasing function. In other words, if a cursor advances in the transformed text, the cusrsor in the original text must advance or stay there.

Parameters
int offset

offset in transformed text

Returns
int

offset in original text