~ubuntu-branches/debian/lenny/mono/lenny

« back to all changes in this revision

Viewing changes to tools/locale-builder/NumberFormatEntry.cs

  • Committer: Bazaar Package Importer
  • Author(s): Debian Mono Group
  • Date: 2004-06-19 14:38:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040619143857-pycck6oxgwd172zc
Tags: upstream-0.96
ImportĀ upstreamĀ versionĀ 0.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 ("\"" + EncodeString (CurrencyDecimalSeparator) + "\", ");
 
58
                        builder.Append ("\"" + EncodeString (CurrencyGroupSeparator) + "\", ");
 
59
                        builder.Append ("\"" + EncodeString (PercentDecimalSeparator) + "\", ");
 
60
                        builder.Append ("\"" + EncodeString (PercentGroupSeparator) + "\", ");
 
61
                        builder.Append ("\"" + EncodeString (NumberDecimalSeparator) + "\", ");
 
62
                        builder.Append ("\"" + EncodeString (NumberGroupSeparator) + "\", ");
 
63
 
 
64
                        builder.Append ("\"" + EncodeString (CurrencySymbol) + "\", ");
 
65
                        builder.Append ("\"" + EncodeString (PercentSymbol) + "\", ");
 
66
                        builder.Append ("\"" + EncodeString (NaNSymbol) + "\", ");
 
67
                        builder.Append ("\"" + EncodeString (PerMilleSymbol) + "\", ");
 
68
                        builder.Append ("\"" + EncodeString (NegativeInfinitySymbol) + "\", ");
 
69
                        builder.Append ("\"" + EncodeString (PositiveInfinitySymbol) + "\", ");
 
70
 
 
71
                        builder.Append ("\"" + EncodeString (NegativeSign) + "\", ");
 
72
                        builder.Append ("\"" + EncodeString (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