Class CollationDataBuilder.DataBuilderCollationIterator

java.lang.Object
com.ibm.icu.impl.coll.CollationIterator
com.ibm.icu.impl.coll.CollationDataBuilder.DataBuilderCollationIterator
Enclosing class:
CollationDataBuilder

private static final class CollationDataBuilder.DataBuilderCollationIterator extends CollationIterator
Build-time collation element and character iterator. Uses the runtime CollationIterator for fetching CEs for a string but reads from the builder's unfinished data structures. In particular, this class reads from the unfinished trie and has to avoid CollationIterator.nextCE() and redirect other calls to data.getCE32() and data.getCE32FromSupplementary(). We do this so that we need not implement the collation algorithm again for the builder and make it behave exactly like the runtime code. That would be more difficult to test and maintain than this indirection. Some CE32 tags (for example, the DIGIT_TAG) do not occur in the builder data, so the data accesses from those code paths need not be modified. This class iterates directly over whole code points so that the CollationIterator does not need the finished trie for handling the LEAD_SURROGATE_TAG.
  • Field Details

  • Constructor Details

  • Method Details

    • fetchCEs

      int fetchCEs(CharSequence str, int start, long[] ces, int cesLength)
    • resetToOffset

      public void resetToOffset(int newOffset)
      Description copied from class: CollationIterator
      Resets the iterator state and sets the position to the specified offset. Subclasses must implement, and must call the parent class method, or CollationIterator.reset().
      Specified by:
      resetToOffset in class CollationIterator
    • getOffset

      public int getOffset()
      Specified by:
      getOffset in class CollationIterator
    • nextCodePoint

      public int nextCodePoint()
      Description copied from class: CollationIterator
      Returns the next code point (with post-increment). Public for identical-level comparison and for testing.
      Specified by:
      nextCodePoint in class CollationIterator
    • previousCodePoint

      public int previousCodePoint()
      Description copied from class: CollationIterator
      Returns the previous code point (with pre-decrement). Public for identical-level comparison and for testing.
      Specified by:
      previousCodePoint in class CollationIterator
    • forwardNumCodePoints

      protected void forwardNumCodePoints(int num)
      Specified by:
      forwardNumCodePoints in class CollationIterator
    • backwardNumCodePoints

      protected void backwardNumCodePoints(int num)
      Specified by:
      backwardNumCodePoints in class CollationIterator
    • getDataCE32

      protected int getDataCE32(int c)
      Description copied from class: CollationIterator
      Returns the CE32 from the data trie. Normally the same as data.getCE32(), but overridden in the builder. Call this only when the faster data.getCE32() cannot be used.
      Overrides:
      getDataCE32 in class CollationIterator
    • getCE32FromBuilderData

      protected int getCE32FromBuilderData(int ce32)
      Overrides:
      getCE32FromBuilderData in class CollationIterator