/// <summary> /// Adds a new FieldContainer with MessageFormat.Field.ARGUMENT field, /// argnumber, begin and end index to the fields vector, or sets the /// position's begin and end index if it has MessageFormat.Field.ARGUMENT as /// its field attribute. /// </summary> /// /// <param name="begin"></param> /// <param name="end"></param> /// <param name="argnumber"></param> /// <param name="position"></param> /// <param name="fields"></param> private void HandleArgumentField(int begin, int end, int argnumber, FieldPosition position, List <FieldContainer> fields) { if (fields != null) { fields.Add(new MessageFormat.FieldContainer(begin, end, MessageFormat.Field.ARGUMENT, ((int)(argnumber)))); } else { if (position != null && (Object)position.GetFieldAttribute() == (Object)MessageFormat.Field.ARGUMENT && position.GetEndIndex() == 0) { position.SetBeginIndex(begin); position.SetEndIndex(end); } } }
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()); }