| 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 * from a Map into an object form. | 38 * from a Map into an object form. |
| 39 */ | 39 */ |
| 40 Function _creationFunction; | 40 Function _creationFunction; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * The set of available locales. | 43 * The set of available locales. |
| 44 */ | 44 */ |
| 45 Set availableLocaleSet; | 45 Set availableLocaleSet; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * The constructor. The [uriString] specifies where the data comes | 48 * The constructor. The [_reader] specifies where the data comes |
| 49 * from. The [_creationFunction] creates the appropriate data type | 49 * from. The [_creationFunction] creates the appropriate data type |
| 50 * from the remote data (which typically comes in as a Map). The | 50 * from the remote data (which typically comes in as a Map). The |
| 51 * [keys] lists the set of remotely available locale names so we know which | 51 * [keys] lists the set of remotely available locale names so we know which |
| 52 * things can be fetched without having to check remotely. | 52 * things can be fetched without having to check remotely. |
| 53 */ | 53 */ |
| 54 LazyLocaleData(this._reader, this._creationFunction, List keys) { | 54 LazyLocaleData(this._reader, this._creationFunction, List keys) { |
| 55 map = new Map(); | 55 map = new Map(); |
| 56 availableLocales = keys; | 56 availableLocales = keys; |
| 57 availableLocaleSet = new Set.from(availableLocales); | 57 availableLocaleSet = new Set.from(availableLocales); |
| 58 } | 58 } |
| (...skipping 45 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 |