1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2012-2014, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 ******************************************************************************* 9 * IterCollationIterator.java, ported from uitercollationiterator.h/.cpp 10 * 11 * C++ version created on: 2012sep23 (from utf16collationiterator.h) 12 * created by: Markus W. Scherer 13 */ 14 15 package ohos.global.icu.impl.coll; 16 17 import ohos.global.icu.text.UCharacterIterator; 18 19 /** 20 * UCharIterator-based collation element and character iterator. 21 * Handles normalized text, with length or NUL-terminated. 22 * Unnormalized text is handled by a subclass. 23 * @hide exposed on OHOS 24 */ 25 public class IterCollationIterator extends CollationIterator { IterCollationIterator(CollationData d, boolean numeric, UCharacterIterator ui)26 public IterCollationIterator(CollationData d, boolean numeric, UCharacterIterator ui) { 27 super(d, numeric); 28 iter = ui; 29 } 30 31 @Override resetToOffset(int newOffset)32 public void resetToOffset(int newOffset) { 33 reset(); 34 iter.setIndex(newOffset); 35 } 36 37 @Override getOffset()38 public int getOffset() { 39 return iter.getIndex(); 40 } 41 42 @Override nextCodePoint()43 public int nextCodePoint() { 44 return iter.nextCodePoint(); 45 } 46 47 @Override previousCodePoint()48 public int previousCodePoint() { 49 return iter.previousCodePoint(); 50 } 51 52 @Override handleNextCE32()53 protected long handleNextCE32() { 54 int c = iter.next(); 55 if(c < 0) { 56 return NO_CP_AND_CE32; 57 } 58 return makeCodePointAndCE32Pair(c, trie.getFromU16SingleLead((char)c)); 59 } 60 61 @Override handleGetTrailSurrogate()62 protected char handleGetTrailSurrogate() { 63 int trail = iter.next(); 64 if(!isTrailSurrogate(trail) && trail >= 0) { iter.previous(); } 65 return (char)trail; 66 } 67 68 @Override forwardNumCodePoints(int num)69 protected void forwardNumCodePoints(int num) { 70 iter.moveCodePointIndex(num); 71 } 72 73 @Override backwardNumCodePoints(int num)74 protected void backwardNumCodePoints(int num) { 75 iter.moveCodePointIndex(-num); 76 } 77 78 protected UCharacterIterator iter; 79 } 80