Пример #1
0
        /// <summary>
        /// Formats the specified object using the rules of this MessageFormat and
        /// returns an AttributedCharacterIterator with the formatted message and
        /// attributes. The AttributedCharacterIterator returned also includes the
        /// attributes from the formats of this MessageFormat.
        /// </summary>
        ///
        /// <param name="object">the object to format</param>
        /// <returns>an AttributedCharacterIterator with the formatted message and
        /// attributes</returns>
        /// <exception cref="IllegalArgumentException">when the arguments in the object array cannot be formattedby this Format</exception>
        public override ILOG.J2CsMapping.Text.AttributedCharacterIterator FormatToCharacterIterator(Object obj0)
        {
            if (obj0 == null)
            {
                throw new NullReferenceException();
            }

            StringBuilder         buffer = new StringBuilder();
            List <FieldContainer> fields = new List <FieldContainer>();

            // format the message, and find fields
            FormatImpl((Object[])obj0, buffer, new FieldPosition(0), fields);

            // create an AttributedString with the formatted buffer
            ILOG.J2CsMapping.Text.AttributedString // create an AttributedString with the formatted buffer
                al = new ILOG.J2CsMapping.Text.AttributedString(buffer.ToString());

            // add MessageFormat field attributes and values to the AttributedString
            for (int i = 0; i < fields.Count; i++)
            {
                MessageFormat.FieldContainer fc = fields[i];
                al.AddAttribute(fc.attribute, fc.value_ren, fc.start, fc.end);
            }

            // return the CharacterIterator from AttributedString
            return(al.GetIterator());
        }
Пример #2
0
 internal AttributedIterator(AttributedString attrString_0)
 {
     this.attrString = attrString_0;
     begin           = 0;
     end             = attrString_0.text.Length;
     offset          = 0;
 }
Пример #3
0
 internal AttributedIterator(AttributedString attrString_0,
                             AttributedCharacterIterator_Constants.Attribute[] attributes, int begin_1,
                             int end_2)
 {
     if (begin_1 < 0 || end_2 > attrString_0.text.Length || begin_1 > end_2)
     {
         throw new ArgumentException();
     }
     this.begin      = begin_1;
     this.end        = end_2;
     offset          = begin_1;
     this.attrString = attrString_0;
     if (attributes != null)
     {
         HashedSet <AttributedCharacterIterator_Constants.Attribute> set = new HashedSet <AttributedCharacterIterator_Constants.Attribute>(
             (attributes.Length * 4 / 3) + 1);
         for (int i = attributes.Length; --i >= 0;)
         {
             ILOG.J2CsMapping.Collections.Generics.Collections.Add(set, attributes[i]);
         }
         attributesAllowed = set;
     }
 }
Пример #4
0
        private ILOG.J2CsMapping.Text.AttributedCharacterIterator FormatToCharacterIteratorImpl(DateTime date)
        {
            StringBuilder        buffer = new StringBuilder();
            List <FieldPosition> fields = new List <FieldPosition>();

            // format the date, and find fields
            FormatImpl(date, buffer, null, fields);

            // create and AttributedString with the formatted buffer
            ILOG.J2CsMapping.Text.AttributedString             // create and AttributedString with the formatted buffer
                al = new ILOG.J2CsMapping.Text.AttributedString(buffer.ToString());

            // add DateFormat field attributes to the AttributedString
            for (int i = 0; i < fields.Count; i++)
            {
                FieldPosition pos       = fields[i];
                Format.Field  attribute = pos.GetFieldAttribute();
                al.AddAttribute(attribute, attribute, pos.GetBeginIndex(),
                                pos.GetEndIndex());
            }

            // return the CharacterIterator from AttributedString
            return(al.GetIterator());
        }