コード例 #1
0
        /// <summary>
        /// Set a new source string iterator for iteration, and reset the
        /// offset to the beginning of the text.
        /// </summary>
        /// <param name="source">The new source string iterator for iteration.</param>
        /// <stable>ICU 2.8</stable>
        public void SetText(CharacterIterator source)
        {
            // Note: In C++, we just setText(source.getText()).
            // In Java, we actually operate on a character iterator.
            // TODO: do we need to remember the iterator in a field?
            // TODO: apparently we don't clone a CharacterIterator in Java,
            // we only clone the text for a UCharacterIterator?? see the old code in the constructors
            UCharacterIterator src = new CharacterIteratorWrapper(source);

            src.SetToStart();
            string_ = src.GetText(); // TODO: do we need to remember the source string in a field?
            CollationIterator newIter;
            bool numeric = rbc_.settings.ReadOnly.IsNumeric;

            if (rbc_.settings.ReadOnly.DontCheckFCD)
            {
                newIter = new IterCollationIterator(rbc_.data, numeric, src);
            }
            else
            {
                newIter = new FCDIterCollationIterator(rbc_.data, numeric, src, 0);
            }
            iter_      = newIter;
            otherHalf_ = 0;
            dir_       = 0;
        }
コード例 #2
0
        /// <summary>
        /// Set a new source string iterator for iteration, and reset the
        /// offset to the beginning of the text.
        /// <para/>
        /// The source iterator's integrity will be preserved since a new copy
        /// will be created for use.
        /// </summary>
        /// <param name="source">The new source string iterator for iteration.</param>
        /// <stable>ICU 2.8</stable>
        public void SetText(UCharacterIterator source)
        {
            string_ = source.GetText(); // TODO: do we need to remember the source string in a field?
                                        // Note: In C++, we just setText(source.getText()).
                                        // In Java, we actually operate on a character iterator.
                                        // (The old code apparently did so only for a CharacterIterator;
                                        // for a UCharacterIterator it also just used source.getText()).
                                        // TODO: do we need to remember the cloned iterator in a field?
            UCharacterIterator src;

            //try
            //{
            src = (UCharacterIterator)source.Clone();
            //}
            //catch (CloneNotSupportedException e)
            //{
            //    // Fall back to ICU 52 behavior of iterating over the text contents
            //    // of the UCharacterIterator.
            //    setText(source.getText());
            //    return;
            //}
            src.SetToStart();
            CollationIterator newIter;
            bool numeric = rbc_.settings.ReadOnly.IsNumeric;

            if (rbc_.settings.ReadOnly.DontCheckFCD)
            {
                newIter = new IterCollationIterator(rbc_.data, numeric, src);
            }
            else
            {
                newIter = new FCDIterCollationIterator(rbc_.data, numeric, src, 0);
            }
            iter_      = newIter;
            otherHalf_ = 0;
            dir_       = 0;
        }