Class CaseMapImpl.StringContextIterator

  • All Implemented Interfaces:
    UCaseProps.ContextIterator
    Enclosing class:
    CaseMapImpl

    public static final class CaseMapImpl.StringContextIterator
    extends java.lang.Object
    implements UCaseProps.ContextIterator
    Implementation of UCaseProps.ContextIterator, iterates over a String. See ustrcase.c/utf16_caseContextIterator().
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int cpLimit  
      protected int cpStart  
      protected int dir  
      protected int index  
      protected int limit  
      protected java.lang.CharSequence s  
    • Constructor Summary

      Constructors 
      Constructor Description
      StringContextIterator​(java.lang.CharSequence src)
      Constructor.
      StringContextIterator​(java.lang.CharSequence src, int cpStart, int cpLimit)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCPLength()  
      int getCPLimit()
      Returns the limit of the code point that was last returned by nextCaseMapCP().
      int getCPStart()
      Returns the start of the code point that was last returned by nextCaseMapCP().
      void moveTo​(int i)  
      void moveToLimit()
      Move to the iteration limit without fetching code points up to there.
      int next()
      Iterate and return the next code point, moving in the direction determined by the reset() call.
      int nextCaseMapCP()
      Iterate forward through the string to fetch the next code point to be case-mapped, and set the context indexes for it.
      void reset​(int direction)
      Reset the iterator for forward or backward iteration.
      void setCPStartAndLimit​(int s, int l)  
      void setLimit​(int lim)
      Set the iteration limit for nextCaseMapCP() to an index within the string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • s

        protected java.lang.CharSequence s
      • index

        protected int index
      • limit

        protected int limit
      • cpStart

        protected int cpStart
      • cpLimit

        protected int cpLimit
      • dir

        protected int dir
    • Constructor Detail

      • StringContextIterator

        public StringContextIterator​(java.lang.CharSequence src)
        Constructor.
        Parameters:
        src - String to iterate over.
      • StringContextIterator

        public StringContextIterator​(java.lang.CharSequence src,
                                     int cpStart,
                                     int cpLimit)
        Constructor.
        Parameters:
        src - String to iterate over.
        cpStart - Start index of the current code point.
        cpLimit - Limit index of the current code point.
    • Method Detail

      • setLimit

        public void setLimit​(int lim)
        Set the iteration limit for nextCaseMapCP() to an index within the string. If the limit parameter is negative or past the string, then the string length is restored as the iteration limit.

        This limit does not affect the next() function which always iterates to the very end of the string.

        Parameters:
        lim - The iteration limit.
      • moveToLimit

        public void moveToLimit()
        Move to the iteration limit without fetching code points up to there.
      • moveTo

        public void moveTo​(int i)
      • nextCaseMapCP

        public int nextCaseMapCP()
        Iterate forward through the string to fetch the next code point to be case-mapped, and set the context indexes for it.

        When the iteration limit is reached (and -1 is returned), getCPStart() will be at the iteration limit.

        Iteration with next() does not affect the position for nextCaseMapCP().

        Returns:
        The next code point to be case-mapped, or <0 when the iteration is done.
      • setCPStartAndLimit

        public void setCPStartAndLimit​(int s,
                                       int l)
      • getCPStart

        public int getCPStart()
        Returns the start of the code point that was last returned by nextCaseMapCP().
      • getCPLimit

        public int getCPLimit()
        Returns the limit of the code point that was last returned by nextCaseMapCP().
      • getCPLength

        public int getCPLength()
      • reset

        public void reset​(int direction)
        Description copied from interface: UCaseProps.ContextIterator
        Reset the iterator for forward or backward iteration.
        Specified by:
        reset in interface UCaseProps.ContextIterator
        Parameters:
        direction - >0: Begin iterating forward from the first code point after the one that is being case-mapped. <0: Begin iterating backward from the first code point before the one that is being case-mapped.
      • next

        public int next()
        Description copied from interface: UCaseProps.ContextIterator
        Iterate and return the next code point, moving in the direction determined by the reset() call.
        Specified by:
        next in interface UCaseProps.ContextIterator
        Returns:
        Next code point, or <0 when the iteration is done.