NumberFormatEntry.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // Mono.Tools.LocaleBuilder.NumberFormatEntry
  3. //
  4. // Author(s):
  5. // Jackson Harper ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  9. using System;
  10. using System.Text;
  11. namespace Mono.Tools.LocaleBuilder {
  12. public class NumberFormatEntry : Entry {
  13. public static readonly int MaxGroupSize = 5;
  14. public int CurrencyDecimalDigits;
  15. public string CurrencyDecimalSeparator;
  16. public string CurrencyGroupSeparator;
  17. public int [] CurrencyGroupSizes;
  18. public int CurrencyNegativePattern;
  19. public int CurrencyPositivePattern;
  20. public string CurrencySymbol;
  21. public string NaNSymbol;
  22. public string NegativeSign;
  23. public int NumberDecimalDigits;
  24. public string NumberDecimalSeparator;
  25. public string NumberGroupSeparator;
  26. public int [] NumberGroupSizes;
  27. public int NumberNegativePattern;
  28. public int PercentDecimalDigits;
  29. public string PercentDecimalSeparator;
  30. public string PercentGroupSeparator;
  31. public int [] PercentGroupSizes;
  32. public int PercentNegativePattern;
  33. public int PercentPositivePattern;
  34. public string PercentSymbol;
  35. public string PerMilleSymbol;
  36. public string PositiveInfinitySymbol;
  37. public string PositiveSign;
  38. public int Row;
  39. public string NegativeInfinitySymbol {
  40. get {
  41. return NegativeSign + PositiveInfinitySymbol;
  42. }
  43. }
  44. public void AppendTableRow (StringBuilder builder)
  45. {
  46. builder.Append ("\t{");
  47. builder.Append (EncodeStringIdx (CurrencyDecimalSeparator) + ", ");
  48. builder.Append (EncodeStringIdx (CurrencyGroupSeparator) + ", ");
  49. builder.Append (EncodeStringIdx (PercentDecimalSeparator) + ", ");
  50. builder.Append (EncodeStringIdx (PercentGroupSeparator) + ", ");
  51. builder.Append (EncodeStringIdx (NumberDecimalSeparator) + ", ");
  52. builder.Append (EncodeStringIdx (NumberGroupSeparator) + ", ");
  53. builder.Append (EncodeStringIdx (CurrencySymbol) + ", ");
  54. builder.Append (EncodeStringIdx (PercentSymbol) + ", ");
  55. builder.Append (EncodeStringIdx (NaNSymbol) + ", ");
  56. builder.Append (EncodeStringIdx (PerMilleSymbol) + ", ");
  57. builder.Append (EncodeStringIdx (NegativeInfinitySymbol) + ", ");
  58. builder.Append (EncodeStringIdx (PositiveInfinitySymbol) + ", ");
  59. builder.Append (EncodeStringIdx (NegativeSign) + ", ");
  60. builder.Append (EncodeStringIdx (PositiveSign) + ", ");
  61. builder.Append (CurrencyNegativePattern + ", ");
  62. builder.Append (CurrencyPositivePattern + ", ");
  63. builder.Append (PercentNegativePattern + ", ");
  64. builder.Append (PercentPositivePattern + ", ");
  65. builder.Append (NumberNegativePattern + ", ");
  66. builder.Append (CurrencyDecimalDigits + ", ");
  67. builder.Append (PercentDecimalDigits + ", ");
  68. builder.Append (NumberDecimalDigits + ", ");
  69. AppendGroupSizes (builder, CurrencyGroupSizes);
  70. builder.Append (", ");
  71. AppendGroupSizes (builder, PercentGroupSizes);
  72. builder.Append (", ");
  73. AppendGroupSizes (builder, NumberGroupSizes);
  74. builder.Append ('}');
  75. }
  76. private void AppendGroupSizes (StringBuilder builder, int [] gs)
  77. {
  78. int len = (gs == null ? 0 : gs.Length);
  79. builder.Append ('{');
  80. for (int i = 0; i < MaxGroupSize; i++) {
  81. if (i < len)
  82. builder.Append (gs [0]);
  83. else
  84. builder.Append (-1);
  85. if (i+1 < MaxGroupSize)
  86. builder.Append (", ");
  87. }
  88. builder.Append ('}');
  89. }
  90. public override string ToString ()
  91. {
  92. StringBuilder builder = new StringBuilder ();
  93. AppendTableRow (builder);
  94. return builder.ToString ();
  95. }
  96. }
  97. }