Exemplo n.º 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());
        }
Exemplo n.º 2
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());
        }