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