Ejemplo n.º 1
0
        private AttributedString(AttributedCharacterIterator iterator, int start_0,
                                 int end_1, ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> attributes)
        {
            if (start_0 < iterator.GetBeginIndex() || end_1 > iterator.GetEndIndex() ||
                start_0 > end_1)
            {
                throw new ArgumentException();
            }

            if (attributes == null)
            {
                return;
            }

            StringBuilder buffer = new StringBuilder();

            iterator.SetIndex(start_0);
            while (iterator.GetIndex() < end_1)
            {
                buffer.Append(iterator.Current());
                iterator.Next();
            }
            text         = buffer.ToString();
            attributeMap = new Dictionary <AttributedCharacterIterator_Constants.Attribute, IList <Range> >(
                (attributes.Count * 4 / 3) + 1);

            IIterator <AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(attributes.GetEnumerator());

            while (it.HasNext())
            {
                AttributedCharacterIterator_Constants.Attribute attribute = it.Next();
                iterator.SetIndex(start_0);
                while (iterator.GetIndex() < end_1)
                {
                    Object value_ren = iterator.GetAttribute(attribute);
                    int    runStart  = iterator.GetRunStart(attribute);
                    int    limit     = iterator.GetRunLimit(attribute);
                    if ((value_ren is ILOG.J2CsMapping.Util.Annotation && runStart >= start_0 && limit <= end_1) ||
                        (value_ren != null && !(value_ren is ILOG.J2CsMapping.Util.Annotation)))
                    {
                        AddAttribute(attribute, value_ren, ((runStart < start_0) ? start_0
                                : runStart) - start_0, ((limit > end_1) ? end_1 : limit)
                                     - start_0);
                    }
                    iterator.SetIndex(limit);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// If fields vector is not null, find and add the fields of this format to
        /// the fields vector by iterating through its AttributedCharacterIterator
        /// </summary>
        ///
        /// <param name="format">the format to find fields for</param>
        /// <param name="arg">object to format</param>
        /// <param name="begin">the index where the string this format has formatted begins</param>
        /// <param name="fields">fields vector, each entry in this vector are of typeFieldContainer.</param>
        private void Handleformat(Format format, Object arg, int begin,
                                  List <FieldContainer> fields)
        {
            if (fields != null)
            {
                AttributedCharacterIterator iterator = format
                                                       .FormatToCharacterIterator(arg);
                while (iterator.GetIndex() != iterator.GetEndIndex())
                {
                    int start_0 = iterator.GetRunStart();
                    int end_1   = iterator.GetRunLimit();

                    IIterator <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(new ILOG.J2CsMapping.Collections.Generics.ListSet <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(iterator.GetAttributes().Keys).GetEnumerator());
                    while (it.HasNext())
                    {
                        AttributedCharacterIterator_Constants.Attribute attribute_2 = (AttributedCharacterIterator_Constants.Attribute)it
                                                                                      .Next();
                        Object value_ren = iterator.GetAttribute(attribute_2);
                        fields.Add(new MessageFormat.FieldContainer(begin + start_0, begin + end_1,
                                                                    attribute_2, value_ren));
                    }
                    iterator.SetIndex(end_1);
                }
            }
        }
Ejemplo n.º 3
0
        public AttributedString(AttributedCharacterIterator iterator)
        {
            if (iterator.GetBeginIndex() > iterator.GetEndIndex())
            {
                // text.0A=Invalid substring range
                throw new ArgumentException("text.0A"); //$NON-NLS-1$
            }
            StringBuilder buffer = new StringBuilder();

            for (int i = iterator.GetBeginIndex(); i < iterator.GetEndIndex(); i++)
            {
                buffer.Append(iterator.Current());
                iterator.Next();
            }
            text = buffer.ToString();
            ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> attributes = iterator
                                                                                                                      .GetAllAttributeKeys();
            if (attributes == null)
            {
                return;
            }
            attributeMap = new Dictionary <AttributedCharacterIterator_Constants.Attribute, IList <Range> >(
                (attributes.Count * 4 / 3) + 1);

            IIterator <AttributedCharacterIterator_Constants.Attribute> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(attributes.GetEnumerator());

            while (it.HasNext())
            {
                AttributedCharacterIterator_Constants.Attribute attribute = it.Next();
                iterator.SetIndex(0);
                while (iterator.Current() != ILOG.J2CsMapping.Text.CharacterIterator.Done)
                {
                    int    start_0   = iterator.GetRunStart(attribute);
                    int    limit     = iterator.GetRunLimit(attribute);
                    Object value_ren = iterator.GetAttribute(attribute);
                    if (value_ren != null)
                    {
                        AddAttribute(attribute, value_ren, start_0, limit);
                    }
                    iterator.SetIndex(limit);
                }
            }
        }