Class 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 Detail

      • jamoCE32s

        protected final int[] jamoCE32s
      • s

        protected java.lang.CharSequence s
      • pos

        protected int pos
    • Method Detail

      • fetchCEs

        int fetchCEs​(java.lang.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
      • 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
      • 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