Exemplo n.º 1
0
        /// <summary>
        /// Set the target text to be searched. Text iteration will then begin at the
        /// start of the text string. This method is useful if you want to reuse an
        /// iterator to search within a different body of text.
        /// </summary>
        ///
        /// <param name="text">new text iterator to look for match,</param>
        /// <exception cref="IllegalArgumentException">thrown when text is null or has 0 length</exception>
        /// <seealso cref="M:IBM.ICU.Text.SearchIterator.GetTarget"/>
        /// @stable ICU 2.4
        public virtual void SetTarget(ICharacterIterator text)
        {
            if (text == null || text.GetEndIndex() == text.GetIndex())
            {
                throw new ArgumentException("Illegal null or empty text");
            }

            targetText = text;
            targetText.SetIndex(targetText.GetBeginIndex());
            matchLength           = 0;
            m_reset_              = true;
            m_isForwardSearching_ = true;
            if (breakIterator != null)
            {
                breakIterator.SetText(targetText);
            }
        }
Exemplo n.º 2
0
        // protected constructor ----------------------------------------------

        /// <summary>
        /// Protected constructor for use by subclasses. Initializes the iterator
        /// with the argument target text for searching and sets the BreakIterator.
        /// See class documentation for more details on the use of the target text
        /// and BreakIterator.
        /// </summary>
        ///
        /// <param name="target">The target text to be searched.</param>
        /// <param name="breaker">A <see cref="T:IBM.ICU.Text.BreakIterator"/> that is used to determine theboundaries of a logical match. This argument can be null.</param>
        /// <exception cref="IllegalArgumentException">thrown when argument target is null, or of length 0</exception>
        /// <seealso cref="T:IBM.ICU.Text.BreakIterator"/>
        /// @stable ICU 2.0
        protected internal SearchIterator(ICharacterIterator target, BreakIterator breaker)
        {
            if (target == null ||
                (target.GetEndIndex() - target.GetBeginIndex()) == 0)
            {
                throw new ArgumentException("Illegal argument target. "
                                            + " Argument can not be null or of length 0");
            }
            targetText    = target;
            breakIterator = breaker;
            if (breakIterator != null)
            {
                breakIterator.SetText(target);
            }
            matchLength           = 0;
            m_lastMatchStart_     = DONE;
            m_isOverlap_          = false;
            m_isForwardSearching_ = true;
            m_reset_     = true;
            m_setOffset_ = DONE;
        }
Exemplo n.º 3
0
 /// <seealso cref="null"/>
 public override int GetLength()
 {
     return(iterator.GetEndIndex() - iterator.GetBeginIndex());
 }