コード例 #1
0
        public void TestArray()
        {
            String[]             list = new String[] { "Fred" };
            IEnumerable <String> i    = Ca.Infoway.Messagebuilder.Util.Iterator.EmptyIterable <String> .NullSafeIterable(list);

            NUnit.Framework.Assert.IsNotNull(i, "iterable");
            IIterator <String> iterator = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <System.String>(i.GetEnumerator());

            NUnit.Framework.Assert.IsNotNull(iterator, "iterator");
            NUnit.Framework.Assert.IsNotNull(iterator.HasNext(), "hasNext()");
            NUnit.Framework.Assert.AreEqual("Fred", iterator.Next(), "next()");
            NUnit.Framework.Assert.IsFalse(iterator.HasNext(), "no more");
        }
コード例 #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);
                }
            }
        }
コード例 #3
0
            public virtual ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> GetAllAttributeKeys()
            {
                if (begin == 0 && end == attrString.text.Length &&
                    attributesAllowed == null)
                {
                    return(new ILOG.J2CsMapping.Collections.Generics.ListSet <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute>(attrString.attributeMap.Keys));
                }

                ILOG.J2CsMapping.Collections.Generics.ISet <AttributedCharacterIterator_Constants.Attribute> result = new HashedSet <AttributedCharacterIterator_Constants.Attribute>(
                    (attrString.attributeMap.Count * 4 / 3) + 1);
                IIterator <KeyValuePair <AttributedCharacterIterator_Constants.Attribute, IList <Range> > > it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <System.Collections.Generic.KeyValuePair <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute, System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range> > >(new ILOG.J2CsMapping.Collections.Generics.ListSet <KeyValuePair <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute, System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range> > >(attrString.attributeMap).GetEnumerator());

                while (it.HasNext())
                {
                    KeyValuePair <AttributedCharacterIterator_Constants.Attribute, IList <Range> > entry = it.Next();
                    if (attributesAllowed == null ||
                        ILOG.J2CsMapping.Collections.Generics.Collections.Contains((ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)entry.Key, attributesAllowed))
                    {
                        IList <Range> ranges = entry.Value;
                        if (InRange(ranges))
                        {
                            ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, entry.Key);
                        }
                    }
                }
                return(result);
            }
コード例 #4
0
            public Object CurrentValue(IList <Range> ranges)
            {
                IIterator <Range> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedString.Range>(ranges.GetEnumerator());

                while (it.HasNext())
                {
                    AttributedString.Range range = it.Next();
                    if (offset >= range.start && offset < range.end)
                    {
                        return((InRange(range)) ? range.value_ren : null);
                    }
                }
                return(null);
            }
コード例 #5
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);
                }
            }
        }
コード例 #6
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);
                }
            }
        }
コード例 #7
0
            public bool InRange(IList <Range> ranges)
            {
                IIterator <Range> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedString.Range>(ranges.GetEnumerator());

                while (it.HasNext())
                {
                    AttributedString.Range range = it.Next();
                    if (range.start >= begin && range.start < end)
                    {
                        return(!(range.value_ren is ILOG.J2CsMapping.Util.Annotation) ||
                               (range.end > begin && range.end <= end));
                    }
                    else if (range.end > begin && range.end <= end)
                    {
                        return(!(range.value_ren is ILOG.J2CsMapping.Util.Annotation) ||
                               (range.start >= begin && range.start < end));
                    }
                }
                return(false);
            }
コード例 #8
0
            public virtual IDictionary <AttributedCharacterIterator_Constants.Attribute, Object> GetAttributes()
            {
                IDictionary <AttributedCharacterIterator_Constants.Attribute, Object> result = new Dictionary <AttributedCharacterIterator_Constants.Attribute, Object>(
                    (attrString.attributeMap.Count * 4 / 3) + 1);
                IIterator <KeyValuePair <AttributedCharacterIterator_Constants.Attribute, IList <Range> > > it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <System.Collections.Generic.KeyValuePair <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute, System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range> > >(new ILOG.J2CsMapping.Collections.Generics.ListSet <KeyValuePair <ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute, System.Collections.Generic.IList <ILOG.J2CsMapping.Text.AttributedString.Range> > >(attrString.attributeMap).GetEnumerator());

                while (it.HasNext())
                {
                    KeyValuePair <AttributedCharacterIterator_Constants.Attribute, IList <Range> > entry = it.Next();
                    if (attributesAllowed == null ||
                        ILOG.J2CsMapping.Collections.Generics.Collections.Contains((ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)entry.Key, attributesAllowed))
                    {
                        Object value_ren = CurrentValue(entry.Value);
                        if (value_ren != null)
                        {
                            ILOG.J2CsMapping.Collections.Generics.Collections.Put(result, (ILOG.J2CsMapping.Text.AttributedCharacterIterator_Constants.Attribute)(entry.Key), (System.Object)(value_ren));
                        }
                    }
                }
                return(result);
            }
コード例 #9
0
            public int RunStart(IList <Range> ranges)
            {
                int result           = begin;
                IIterator <Range> it = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <ILOG.J2CsMapping.Text.AttributedString.Range>(ranges.GetEnumerator());

                while (it.HasNext())
                {
                    AttributedString.Range range = it.Next();
                    if (range.start >= end)
                    {
                        break;
                    }
                    if (offset >= range.start && offset < range.end)
                    {
                        return((InRange(range)) ? range.start : result);
                    }
                    else if (offset < range.start)
                    {
                        break;
                    }
                    result = range.end;
                }
                return(result);
            }
コード例 #10
0
        private IList <CodedValue> ConvertValueSetsToCodedValues(
            IList <ValueSetEntry> valueSets)
        {
            IList <CodedValue> result = new List <CodedValue>();

            for (IIterator <ValueSetEntry> iter = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <Ca.Infoway.Messagebuilder.Terminology.Codeset.Domain.ValueSetEntry>(valueSets.GetEnumerator()); iter
                 .HasNext();)
            {
                ValueSetEntry valueSet = iter.Next();
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, valueSet.CodedValue);
            }

            return(result);
        }
コード例 #11
0
 public void TearDown()
 {
     Ca.Infoway.Messagebuilder.CollUtils.Reverse(this.createdObjects);
     for (IIterator <Object> iterator = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <System.Object>(this.createdObjects.GetEnumerator()); iterator
          .HasNext();)
     {
         Object createdObj = iterator.Next();
         HibernateTemplate.Delete(createdObj);
     }
     ILOG.J2CsMapping.Collections.Generics.Collections.Clear(this.createdObjects);
 }
コード例 #12
0
 private bool CodedValueFound(IList <CodedValue> codedValues, String code)
 {
     for (IIterator <CodedValue> i = new ILOG.J2CsMapping.Collections.Generics.IteratorAdapter <Ca.Infoway.Messagebuilder.Terminology.Codeset.Domain.CodedValue>(codedValues.GetEnumerator()); i.HasNext();)
     {
         CodedValue value_ren = i.Next();
         if (value_ren.Code.Equals(code))
         {
             return(true);
         }
     }
     return(false);
 }