| Index: packages/intl/lib/src/lazy_locale_data.dart
|
| diff --git a/packages/intl/lib/src/lazy_locale_data.dart b/packages/intl/lib/src/lazy_locale_data.dart
|
| index 9be1c0d9a3c331d6bff6312cbdfe2ca078bca642..07d46f7bce4540bbedf611cc40eb8da2ba3f090c 100644
|
| --- a/packages/intl/lib/src/lazy_locale_data.dart
|
| +++ b/packages/intl/lib/src/lazy_locale_data.dart
|
| @@ -2,11 +2,9 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -/**
|
| - * This defines a class for loading locale data incrementally from
|
| - * an external source as JSON. The external sources expected are either
|
| - * local files or via HTTP request.
|
| - */
|
| +/// This defines a class for loading locale data incrementally from
|
| +/// an external source as JSON. The external sources expected are either
|
| +/// local files or via HTTP request.
|
|
|
| library lazy_locale_data;
|
|
|
| @@ -14,11 +12,9 @@ import 'dart:async';
|
| import 'dart:convert';
|
| import 'intl_helpers.dart';
|
|
|
| -/**
|
| - * This implements the very basic map-type operations which are used
|
| - * in locale lookup, and looks them up based on a URL that defines
|
| - * the external source.
|
| - */
|
| +/// This implements the very basic map-type operations which are used
|
| +/// in locale lookup, and looks them up based on a URL that defines
|
| +/// the external source.
|
| class LazyLocaleData {
|
| /// This holds the data we have loaded.
|
| Map map;
|
| @@ -26,52 +22,41 @@ class LazyLocaleData {
|
| /// The object that actually does the data reading.
|
| LocaleDataReader _reader;
|
|
|
| - /**
|
| - * In order to avoid a potentially remote call to see if a locale
|
| - * is available, we hold a complete list of all the available
|
| - * locales.
|
| - */
|
| + /// In order to avoid a potentially remote call to see if a locale
|
| + /// is available, we hold a complete list of all the available
|
| + /// locales.
|
| List availableLocales;
|
|
|
| - /**
|
| - * Given a piece of remote data, apply [_creationFunction] to it to
|
| - * convert it into the right form. Typically this means converting it
|
| - * from a Map into an object form.
|
| - */
|
| + /// Given a piece of remote data, apply [_creationFunction] to it to
|
| + /// convert it into the right form. Typically this means converting it
|
| + /// from a Map into an object form.
|
| Function _creationFunction;
|
|
|
| - /**
|
| - * The set of available locales.
|
| - */
|
| + /// The set of available locales.
|
| Set availableLocaleSet;
|
|
|
| - /**
|
| - * The constructor. The [_reader] specifies where the data comes
|
| - * from. The [_creationFunction] creates the appropriate data type
|
| - * from the remote data (which typically comes in as a Map). The
|
| - * [keys] lists the set of remotely available locale names so we know which
|
| - * things can be fetched without having to check remotely.
|
| - */
|
| + /// The constructor. The [_reader] specifies where the data comes
|
| + /// from. The [_creationFunction] creates the appropriate data type
|
| + /// from the remote data (which typically comes in as a Map). The
|
| + /// [keys] lists the set of remotely available locale names so we know which
|
| + /// things can be fetched without having to check remotely.
|
| LazyLocaleData(this._reader, this._creationFunction, List keys) {
|
| map = new Map();
|
| availableLocales = keys;
|
| availableLocaleSet = new Set.from(availableLocales);
|
| }
|
|
|
| - /**
|
| - * Tests if we have data for the locale available. Note that this returns
|
| - * true even if the data is known to be available remotely but not yet loaded.
|
| - */
|
| + /// Tests if we have data for the locale available. Note that this returns
|
| + /// true even if the data is known to be available remotely but not yet
|
| + /// loaded.
|
| bool containsKey(String locale) => availableLocaleSet.contains(locale);
|
|
|
| - /** Returns the list of keys/locale names. */
|
| + /// Returns the list of keys/locale names.
|
| List get keys => availableLocales;
|
|
|
| - /**
|
| - * Returns the data stored for [localeName]. If no data has been loaded
|
| - * for [localeName], throws an exception. If no data is available for
|
| - * [localeName] then throw an exception with a different message.
|
| - */
|
| + /// Returns the data stored for [localeName]. If no data has been loaded
|
| + /// for [localeName], throws an exception. If no data is available for
|
| + /// [localeName] then throw an exception with a different message.
|
| operator [](String localeName) {
|
| if (containsKey(localeName)) {
|
| var data = map[localeName];
|
| @@ -87,18 +72,14 @@ class LazyLocaleData {
|
| }
|
| }
|
|
|
| - /**
|
| - * Throw an exception indicating that the locale has no data available,
|
| - * either locally or remotely.
|
| - */
|
| + /// Throw an exception indicating that the locale has no data available,
|
| + /// either locally or remotely.
|
| unsupportedLocale(localeName) {
|
| throw new LocaleDataException('Locale $localeName has no data available');
|
| }
|
|
|
| - /**
|
| - * Initialize for locale. Internal use only. As a user, call
|
| - * initializeDateFormatting instead.
|
| - */
|
| + /// Initialize for locale. Internal use only. As a user, call
|
| + /// initializeDateFormatting instead.
|
| Future initLocale(String localeName) {
|
| var data = _reader.read(localeName);
|
| return jsonData(data).then((input) {
|
| @@ -106,10 +87,8 @@ class LazyLocaleData {
|
| });
|
| }
|
|
|
| - /**
|
| - * Given a Future [input] whose value is expected to be a string in JSON form,
|
| - * return another future that parses the JSON into a usable format.
|
| - */
|
| + /// Given a Future [input] whose value is expected to be a string in JSON
|
| + /// form, return another future that parses the JSON into a usable format.
|
| Future jsonData(Future input) {
|
| return input.then((response) => JSON.decode(response));
|
| }
|
|
|