|
1 | 1 | note |
2 | | - description: "Summary description for {EG_NUMBER_FORMAT_TYPE}." |
3 | | - author: "" |
| 2 | + description: "[ |
| 3 | + The number format of the cell. In this documentation the locale is assumed to be en_US, but the actual format depends on the locale of the spreadsheet. |
| 4 | + |
| 5 | + Enums |
| 6 | + NUMBER_FORMAT_TYPE_UNSPECIFIED The number format is not specified and is based on the contents of the cell. Do not explicitly use this. |
| 7 | + TEXT Text formatting, e.g 1000.12 |
| 8 | + NUMBER Number formatting, e.g, 1,000.12 |
| 9 | + PERCENT Percent formatting, e.g 10.12% |
| 10 | + CURRENCY Currency formatting, e.g $1,000.12 |
| 11 | + DATE Date formatting, e.g 9/26/2008 |
| 12 | + TIME Time formatting, e.g 3:59:00 PM |
| 13 | + DATE_TIME Date+Time formatting, e.g 9/26/08 15:59:00 |
| 14 | + SCIENTIFIC Scientific number formatting, e.g 1.01E+03 |
| 15 | + ]" |
4 | 16 | date: "$Date$" |
5 | 17 | revision: "$Revision$" |
6 | 18 |
|
7 | 19 | class |
8 | 20 | EG_NUMBER_FORMAT_TYPE |
9 | 21 |
|
| 22 | +inherit |
| 23 | + |
| 24 | + EG_ENUM |
| 25 | + redefine |
| 26 | + default_create |
| 27 | + end |
| 28 | + |
| 29 | +create |
| 30 | + default_create |
| 31 | + |
| 32 | +feature {NONE} -- Initialization |
| 33 | + |
| 34 | + default_create |
| 35 | + do |
| 36 | + Precursor |
| 37 | + set_value (number_format_type_unspecified) |
| 38 | + end |
| 39 | + |
| 40 | + number_format_type_unspecified: INTEGER = 1 |
| 41 | + -- The number format is not specified and is based on the contents of the cell. Do not explicitly use this. |
| 42 | + |
| 43 | + text: INTEGER = 2 |
| 44 | + -- Text formatting, e.g 1000.12. |
| 45 | + |
| 46 | + number: INTEGER = 3 |
| 47 | + -- Number formatting, e.g, 1,000.12 |
| 48 | + |
| 49 | + percent: INTEGER = 3 |
| 50 | + -- Percent formatting, e.g 10.12% |
| 51 | + |
| 52 | + currency: INTEGER = 4 |
| 53 | + -- Currency formatting, e.g $1,000.12 |
| 54 | + |
| 55 | + date: INTEGER = 5 |
| 56 | + -- Date formatting, e.g 9/26/2008 |
| 57 | + |
| 58 | + time: INTEGER = 6 |
| 59 | + -- Time formatting, e.g 3:59:00 PM. |
| 60 | + |
| 61 | + date_time: INTEGER = 7 |
| 62 | + -- Date+Time formatting, e.g 9/26/08 15:59:00 |
| 63 | + |
| 64 | + scientific: INTEGER = 8 |
| 65 | + -- Scientific number formatting, e.g 1.01E+03 |
| 66 | + |
| 67 | + |
| 68 | +feature -- Change Elements |
| 69 | + |
| 70 | + set_text |
| 71 | + do |
| 72 | + set_value (text) |
| 73 | + ensure |
| 74 | + value_set_with_text: value = text |
| 75 | + end |
| 76 | + |
| 77 | + set_number |
| 78 | + do |
| 79 | + set_value (number) |
| 80 | + ensure |
| 81 | + value_set_with_number: value = number |
| 82 | + end |
| 83 | + |
| 84 | + set_percent |
| 85 | + do |
| 86 | + set_value (percent) |
| 87 | + ensure |
| 88 | + value_set_with_percent: value = percent |
| 89 | + end |
| 90 | + |
| 91 | + set_currency |
| 92 | + do |
| 93 | + set_value (currency) |
| 94 | + ensure |
| 95 | + value_set_with_currency: value = currency |
| 96 | + end |
| 97 | + |
| 98 | + set_date |
| 99 | + do |
| 100 | + set_value (date) |
| 101 | + ensure |
| 102 | + value_set_with_date: value = date |
| 103 | + end |
| 104 | + |
| 105 | + set_time |
| 106 | + do |
| 107 | + set_value (time) |
| 108 | + ensure |
| 109 | + value_set_with_time: value = time |
| 110 | + end |
| 111 | + |
| 112 | + set_date_time |
| 113 | + do |
| 114 | + set_value (date_time) |
| 115 | + ensure |
| 116 | + value_set_with_time: value = date_time |
| 117 | + end |
| 118 | + |
| 119 | + set_scientific |
| 120 | + do |
| 121 | + set_value (scientific) |
| 122 | + ensure |
| 123 | + value_set_with_time: value = scientific |
| 124 | + end |
| 125 | + |
| 126 | + |
| 127 | +feature -- Status Report |
| 128 | + |
| 129 | + is_text: BOOLEAN |
| 130 | + do |
| 131 | + Result := value = text |
| 132 | + end |
| 133 | + |
| 134 | + is_number: BOOLEAN |
| 135 | + do |
| 136 | + Result := value = number |
| 137 | + end |
| 138 | + |
| 139 | + is_percent: BOOLEAN |
| 140 | + do |
| 141 | + Result := value = percent |
| 142 | + end |
| 143 | + |
| 144 | + is_currency: BOOLEAN |
| 145 | + do |
| 146 | + Result := value = currency |
| 147 | + end |
| 148 | + |
| 149 | + is_date: BOOLEAN |
| 150 | + do |
| 151 | + Result := value = date |
| 152 | + end |
| 153 | + |
| 154 | + |
| 155 | + is_time: BOOLEAN |
| 156 | + do |
| 157 | + Result := value = time |
| 158 | + end |
| 159 | + |
| 160 | + is_date_time: BOOLEAN |
| 161 | + do |
| 162 | + Result := value = date_time |
| 163 | + end |
| 164 | + |
| 165 | + is_scientific: BOOLEAN |
| 166 | + do |
| 167 | + Result := value = scientific |
| 168 | + end |
| 169 | + |
| 170 | + is_valid_value (a_value: INTEGER): BOOLEAN |
| 171 | + -- Can `a_value' be used in a `set_value' feature call? |
| 172 | + do |
| 173 | + Result := a_value = number_format_type_unspecified or else |
| 174 | + a_value = text or else |
| 175 | + a_value = number or else |
| 176 | + a_value = percent or else |
| 177 | + a_value = currency or else |
| 178 | + a_value = date or else |
| 179 | + a_value = time or else |
| 180 | + a_value = date_time or else |
| 181 | + a_value = scientific |
| 182 | + end |
| 183 | + |
| 184 | + |
| 185 | +feature -- Eiffel to JSON |
| 186 | + |
| 187 | + to_json: JSON_STRING |
| 188 | + -- Json representation of current object. |
| 189 | + do |
| 190 | + if is_text then |
| 191 | + Result := "TEXT" |
| 192 | + elseif is_number then |
| 193 | + Result := "NUMBER" |
| 194 | + elseif is_percent then |
| 195 | + Result := "PERCENT" |
| 196 | + elseif is_currency then |
| 197 | + Result := "CURRENCY" |
| 198 | + elseif is_date then |
| 199 | + Result := "DATE" |
| 200 | + elseif is_time then |
| 201 | + Result := "TIME" |
| 202 | + elseif is_date_time then |
| 203 | + Result := "DATE_TIME" |
| 204 | + else |
| 205 | + Result := "NUMBER_FORMAT_TYPE_UNSPECIFIED" |
| 206 | + end |
| 207 | + end |
| 208 | + |
10 | 209 | end |
0 commit comments