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); } } }
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); } } }