Class Edits.Iterator
- java.lang.Object
-
- com.ibm.icu.text.Edits.Iterator
-
- Enclosing class:
- Edits
public static final class Edits.Iterator extends java.lang.Object
Access to the list of edits.- See Also:
Edits.getCoarseIterator()
,Edits.getFineIterator()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
destinationIndex()
int
destinationIndexFromSourceIndex(int i)
Returns the destination index corresponding to the given source index.boolean
findDestinationIndex(int i)
Finds the edit that contains the destination index.boolean
findSourceIndex(int i)
Finds the edit that contains the source index.boolean
hasChange()
int
newLength()
boolean
next()
Advances to the next edit.int
oldLength()
int
replacementIndex()
int
sourceIndex()
int
sourceIndexFromDestinationIndex(int i)
Returns the source index corresponding to the given destination index.
-
-
-
Method Detail
-
next
public boolean next()
Advances to the next edit.- Returns:
- true if there is another edit
-
findSourceIndex
public boolean findSourceIndex(int i)
Finds the edit that contains the source index. The source index may be found in a non-change even if normal iteration would skip non-changes. 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
- source index- Returns:
- true if the edit for the source index was found
-
findDestinationIndex
public boolean findDestinationIndex(int i)
Finds the edit that contains the destination index. The destination index may be found in a non-change even if normal iteration would skip non-changes. 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
- destination index- Returns:
- true if the edit for the destination index was found
-
destinationIndexFromSourceIndex
public int destinationIndexFromSourceIndex(int i)
Returns 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
- source index- Returns:
- destination index; undefined if i is not 0..string length
-
sourceIndexFromDestinationIndex
public int sourceIndexFromDestinationIndex(int i)
Returns 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
- destination index- Returns:
- source index; undefined if i is not 0..string length
-
hasChange
public boolean hasChange()
- Returns:
- true if this edit replaces oldLength() units with newLength() different ones. false if oldLength units remain unchanged.
-
oldLength
public int oldLength()
- Returns:
- the number of units in the original string which are replaced or remain unchanged.
-
newLength
public int newLength()
- Returns:
- the number of units in the modified string, if hasChange() is true. Same as oldLength if hasChange() is false.
-
sourceIndex
public int sourceIndex()
- Returns:
- the current index into the source string
-
replacementIndex
public int replacementIndex()
- Returns:
- the current index into the replacement-characters-only string, not counting unchanged spans
-
destinationIndex
public int destinationIndex()
- Returns:
- the current index into the full destination string
-
-