Path: blob/trunk/third_party/closure/goog/i18n/uchar/localnamefetcher.js
2868 views
// Copyright 2012 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Object which fetches Unicode codepoint names that are locally16* stored in a bundled database. Currently, only invisible characters are17* covered by this database. See the goog.i18n.uChar.RemoteNameFetcher class for18* a remote database option.19*/2021goog.provide('goog.i18n.uChar.LocalNameFetcher');2223goog.require('goog.i18n.uChar.NameFetcher');24goog.require('goog.i18n.uCharNames');25goog.require('goog.log');26272829/**30* Builds the NameFetcherLocal object. This is a simple object which retrieves31* character names from a local bundled database. This database only covers32* invisible characters. See the goog.i18n.uChar class for more details.33*34* @constructor35* @implements {goog.i18n.uChar.NameFetcher}36* @final37*/38goog.i18n.uChar.LocalNameFetcher = function() {};394041/**42* A reference to the LocalNameFetcher logger.43*44* @type {goog.log.Logger}45* @private46*/47goog.i18n.uChar.LocalNameFetcher.logger_ =48goog.log.getLogger('goog.i18n.uChar.LocalNameFetcher');495051/** @override */52goog.i18n.uChar.LocalNameFetcher.prototype.prefetch = function(character) {};535455/** @override */56goog.i18n.uChar.LocalNameFetcher.prototype.getName = function(57character, callback) {58var localName = goog.i18n.uCharNames.toName(character);59if (!localName) {60goog.i18n.uChar.LocalNameFetcher.logger_.warning(61'No local name defined for character ' + character);62}63callback(localName);64};656667/** @override */68goog.i18n.uChar.LocalNameFetcher.prototype.isNameAvailable = function(69character) {70return !!goog.i18n.uCharNames.toName(character);71};727374