OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * This defines a class for loading locale data incrementally from | 6 * This defines a class for loading locale data incrementally from |
7 * an external source as JSON. The external sources expected are either | 7 * an external source as JSON. The external sources expected are either |
8 * local files or via HTTP request. | 8 * local files or via HTTP request. |
9 */ | 9 */ |
10 | 10 |
11 library lazy_locale_data; | 11 #library('lazy_locale_data'); |
12 import 'dart:uri'; | 12 #import('dart:uri'); |
13 import 'intl_helpers.dart'; | 13 #import('intl_helpers.dart'); |
14 import 'dart:json'; | 14 #import('dart:json'); |
15 | 15 |
16 /** | 16 /** |
17 * This implements the very basic map-type operations which are used | 17 * This implements the very basic map-type operations which are used |
18 * in locale lookup, and looks them up based on a URL that defines | 18 * in locale lookup, and looks them up based on a URL that defines |
19 * the external source. | 19 * the external source. |
20 */ | 20 */ |
21 class LazyLocaleData { | 21 class LazyLocaleData { |
22 /// This holds the data we have loaded. | 22 /// This holds the data we have loaded. |
23 Map map; | 23 Map map; |
24 | 24 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 /** | 106 /** |
107 * Given a Future [input] whose value is expected to be a string in JSON form, | 107 * Given a Future [input] whose value is expected to be a string in JSON form, |
108 * return another future that parses the JSON into a usable format. | 108 * return another future that parses the JSON into a usable format. |
109 */ | 109 */ |
110 Future jsonData(Future input) { | 110 Future jsonData(Future input) { |
111 return input.transform( (response) => JSON.parse(response)); | 111 return input.transform( (response) => JSON.parse(response)); |
112 } | 112 } |
113 } | 113 } |
OLD | NEW |