# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Methods | Inherited Methods

# Edits.Iterator

`public static final class Edits.Iterator`
`extends Object` ``

java.lang.Object
↳ | android.icu.text.Edits.Iterator

Access to the list of edits.

At any moment in time, an instance of this class points to a single edit: a "window" into a span of the source string and the corresponding span of the destination string. The source string span starts at `sourceIndex()` and runs for `oldLength()` chars; the destination string span starts at `destinationIndex()` and runs for `newLength()` chars.

The iterator can be moved between edits using the `next()` and `findSourceIndex(int)` methods. Calling any of these methods mutates the iterator to make it point to the corresponding edit.

For more information, see the documentation for `Edits`.

Note: Although this class is called "Iterator", it does not implement `Iterator`.

See also:

- `Edits.getCoarseIterator()`
- `Edits.getFineIterator()`

## Summary

### Public methods
`int` | `destinationIndex()` The start index of the current span in the destination string; the span has length `newLength()`.
`int` | `destinationIndexFromSourceIndex(int i)` Computes the destination index corresponding to the given source index.
`boolean` | `findDestinationIndex(int i)` Moves the iterator to the edit that contains the destination index.
`boolean` | `findSourceIndex(int i)` Moves the iterator to the edit that contains the source index.
`boolean` | `hasChange()` Returns whether the edit currently represented by the iterator is a change edit.
`int` | `newLength()` The length of the current span in the destination string, which starts at `destinationIndex()`, or in the replacement string, which starts at `replacementIndex()`.
`boolean` | `next()` Advances the iterator to the next edit.
`int` | `oldLength()` The length of the current span in the source string, which starts at `sourceIndex()`.
`int` | `replacementIndex()` The start index of the current span in the replacement string; the span has length `newLength()`.
`int` | `sourceIndex()` The start index of the current span in the source string; the span has length `oldLength()`.
`int` | `sourceIndexFromDestinationIndex(int i)` Computes the source index corresponding to the given destination index.
`String` | `toString()` A string representation of the current edit represented by the iterator for debugging.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public methods

### destinationIndex

    public int destinationIndex ()

The start index of the current span in the destination string; the span has length `newLength()`.

Returns
`int` | the current index into the full destination string

### destinationIndexFromSourceIndex

    public int destinationIndexFromSourceIndex (int i)

Computes the destination index corresponding to the given source index. If the source index is inside a change edit (not at its start), then the destination index at the end of that edit is returned, since there is no information about index mapping inside a change edit.

(This means that indexes to the start and middle of an edit, for example around a grapheme cluster, are mapped to indexes encompassing the entire edit. The alternative, mapping an interior index to the start, would map such an interval to an empty one.)

This operation will usually but not always modify this object. The iterator state after this search is undefined.

Parameters
`i` | `int`: source index

Returns
`int` | destination index; undefined if i is not 0..string length

### findDestinationIndex

    public boolean findDestinationIndex (int i)

Moves the iterator to the edit that contains the destination index. The destination index may be found in a no-change edit even if normal iteration would skip no-change edits. Normal iteration can continue from a found edit.

The iterator state before this search logically does not matter. (It may affect the performance of the search.)

The iterator state after this search is undefined if the source index is out of bounds for the source string.

Parameters
`i` | `int`: destination index

Returns
`boolean` | true if the edit for the destination index was found

### findSourceIndex

    public boolean findSourceIndex (int i)

Moves the iterator to the edit that contains the source index. The source index may be found in a no-change edit even if normal iteration would skip no-change edits. Normal iteration can continue from a found edit.

The iterator state before this search logically does not matter. (It may affect the performance of the search.)

The iterator state after this search is undefined if the source index is out of bounds for the source string.

Parameters
`i` | `int`: source index

Returns
`boolean` | true if the edit for the source index was found

### hasChange

    public boolean hasChange ()

Returns whether the edit currently represented by the iterator is a change edit.

Returns
`boolean` | true if this edit replaces oldLength() units with newLength() different ones. false if oldLength units remain unchanged.

### newLength

    public int newLength ()

The length of the current span in the destination string, which starts at `destinationIndex()`, or in the replacement string, which starts at `replacementIndex()`.

Returns
`int` | the number of units in the destination string, if hasChange() is true. Same as oldLength if hasChange() is false.

### next

    public boolean next ()

Advances the iterator to the next edit.

Returns
`boolean` | true if there is another edit

### oldLength

    public int oldLength ()

The length of the current span in the source string, which starts at `sourceIndex()`.

Returns
`int` | the number of units in the source string which are replaced or remain unchanged.

### replacementIndex

    public int replacementIndex ()

The start index of the current span in the replacement string; the span has length `newLength()`. Well-defined only if the current edit is a change edit.

The replacement string is the concatenation of all substrings of the destination string corresponding to change edits.

This method is intended to be used together with operations that write only replacement characters (e.g., `CaseMap#omitUnchangedText()`). The source string can then be modified in-place.

Returns
`int` | the current index into the replacement-characters-only string, not counting unchanged spans

### sourceIndex

    public int sourceIndex ()

The start index of the current span in the source string; the span has length `oldLength()`.

Returns
`int` | the current index into the source string

### sourceIndexFromDestinationIndex

    public int sourceIndexFromDestinationIndex (int i)

Computes the source index corresponding to the given destination index. If the destination index is inside a change edit (not at its start), then the source index at the end of that edit is returned, since there is no information about index mapping inside a change edit.

(This means that indexes to the start and middle of an edit, for example around a grapheme cluster, are mapped to indexes encompassing the entire edit. The alternative, mapping an interior index to the start, would map such an interval to an empty one.)

This operation will usually but not always modify this object. The iterator state after this search is undefined.

Parameters
`i` | `int`: destination index

Returns
`int` | source index; undefined if i is not 0..string length

### toString

    public String toString ()

A string representation of the current edit represented by the iterator for debugging. You should not depend on the contents of the return string; it may change over time.

Returns
`String` | a string representation of the object.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*