public void AddAttribute(AttributedCharacterIterator_Constants.Attribute attribute, Object value_ren) { if (null == attribute) { throw new NullReferenceException(); } if (text.Length == 0) { throw new ArgumentException(); } IList <Range> ranges = ((System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range>)ILOG.J2CsMapping.Collections.Generics.Collections.Get(attributeMap, attribute)); if (ranges == null) { ranges = new List <Range>(1); ILOG.J2CsMapping.Collections.Generics.Collections.Put(attributeMap, (ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)(attribute), (System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range>)(ranges)); } else { ILOG.J2CsMapping.Collections.Generics.Collections.Clear(ranges); } ILOG.J2CsMapping.Collections.Generics.Collections.Add(ranges, new AttributedString.Range(0, text.Length, value_ren)); }
public virtual int GetRunStart(AttributedCharacterIterator_Constants.Attribute attribute) { if (attributesAllowed != null && !ILOG.J2CsMapping.Collections.Generics.Collections.Contains((ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)attribute, attributesAllowed)) { return(begin); } List <Range> ranges = (List <Range>)((System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range>)ILOG.J2CsMapping.Collections.Generics.Collections.Get(attrString.attributeMap, attribute)); if (ranges == null) { return(begin); } return(RunStart(ranges)); }
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 virtual int GetRunStart <T0>(ILOG.J2CsMapping.Collections.Generics.ISet <T0> attributes) where T0 : AttributedCharacterIterator_Constants.Attribute { int start_0 = begin; IIterator <T0> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <T0>(attributes.GetEnumerator()); while (it.HasNext()) { AttributedCharacterIterator_Constants.Attribute attribute = it.Next(); int newStart = GetRunStart(attribute); if (newStart > start_0) { start_0 = newStart; } } return(start_0); }
public virtual int GetRunLimit <T0>(ILOG.J2CsMapping.Collections.Generics.ISet <T0> attributes) where T0 : AttributedCharacterIterator_Constants.Attribute { int limit = end; IIterator <T0> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <T0>(attributes.GetEnumerator()); while (it.HasNext()) { AttributedCharacterIterator_Constants.Attribute attribute = it.Next(); int newLimit = GetRunLimit(attribute); if (newLimit < limit) { limit = newLimit; } } return(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); } } }
public void AddAttribute(AttributedCharacterIterator_Constants.Attribute attribute, Object value_ren, int start_0, int end_1) { if (null == attribute) { throw new NullReferenceException(); } if (start_0 < 0 || end_1 > text.Length || start_0 >= end_1) { throw new ArgumentException(); } if (value_ren == null) { return; } IList <Range> ranges = ((System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range>)ILOG.J2CsMapping.Collections.Generics.Collections.Get(attributeMap, attribute)); if (ranges == null) { ranges = new List <Range>(1); ILOG.J2CsMapping.Collections.Generics.Collections.Add(ranges, new AttributedString.Range(start_0, end_1, value_ren)); ILOG.J2CsMapping.Collections.Generics.Collections.Put(attributeMap, (ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)(attribute), (System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range>)(ranges)); return; } IListIterator <Range> it = new ArrayListIterator <Range>(ranges); while (it.HasNext()) { // foreach(Range range in ranges) { AttributedString.Range range = it.Next(); if (end_1 <= range.start) { it.Previous(); break; } else if (start_0 < range.end || (start_0 == range.end && value_ren.Equals(range.value_ren))) { AttributedString.Range r1 = null, r3; it.Remove(); r1 = new AttributedString.Range(range.start, start_0, range.value_ren); r3 = new AttributedString.Range(end_1, range.end, range.value_ren); while (end_1 > range.end && it.HasNext()) { range = it.Next(); if (end_1 <= range.end) { if (end_1 > range.start || (end_1 == range.start && value_ren .Equals(range.value_ren))) { it.Remove(); r3 = new AttributedString.Range(end_1, range.end, range.value_ren); break; } } else { it.Remove(); } } if (value_ren.Equals(r1.value_ren)) { if (value_ren.Equals(r3.value_ren)) { it.Add(new AttributedString.Range((r1.start < start_0) ? r1.start : start_0, (r3.end > end_1) ? r3.end : end_1, r1.value_ren)); } else { it.Add(new AttributedString.Range((r1.start < start_0) ? r1.start : start_0, end_1, r1.value_ren)); if (r3.start < r3.end) { it.Add(r3); } } } else { if (value_ren.Equals(r3.value_ren)) { if (r1.start < r1.end) { it.Add(r1); } it.Add(new AttributedString.Range(start_0, (r3.end > end_1) ? r3.end : end_1, r3.value_ren)); } else { if (r1.start < r1.end) { it.Add(r1); } it.Add(new AttributedString.Range(start_0, end_1, value_ren)); if (r3.start < r3.end) { it.Add(r3); } } } return; } } it.Add(new AttributedString.Range(start_0, end_1, value_ren)); }