~launchpad-pqm/lazr-js/toolchain

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/dataschema/dataschema-base-debug.js

  • Committer: Sidnei da Silva
  • Date: 2009-11-16 00:51:29 UTC
  • mto: This revision was merged to the branch mainline in revision 154.
  • Revision ID: sidnei.da.silva@canonical.com-20091116005129-8ibwjlboa38glaw5
- Improved generation of skin modules and revamped combo service to make it more twisty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
 
Code licensed under the BSD License:
4
 
http://developer.yahoo.com/yui/license.html
5
 
version: 3.2.0
6
 
build: 2676
7
 
*/
8
 
YUI.add('dataschema-base', function(Y) {
9
 
 
10
 
/**
11
 
 * The DataSchema utility provides a common configurable interface for widgets to
12
 
 * apply a given schema to a variety of data.
13
 
 *
14
 
 * @module dataschema
15
 
 */
16
 
 
17
 
/**
18
 
 * Provides the base DataSchema implementation, which can be extended to 
19
 
 * create DataSchemas for specific data formats, such XML, JSON, text and
20
 
 * arrays.
21
 
 *
22
 
 * @module dataschema
23
 
 * @submodule dataschema-base
24
 
 */
25
 
 
26
 
var LANG = Y.Lang,
27
 
/**
28
 
 * Base class for the YUI DataSchema Utility.
29
 
 * @class DataSchema.Base
30
 
 * @static
31
 
 */
32
 
    SchemaBase = {
33
 
    /**
34
 
     * Overridable method returns data as-is.
35
 
     *
36
 
     * @method apply
37
 
     * @param schema {Object} Schema to apply.
38
 
     * @param data {Object} Data.
39
 
     * @return {Object} Schema-parsed data.
40
 
     * @static
41
 
     */
42
 
    apply: function(schema, data) {
43
 
        return data;
44
 
    },
45
 
    
46
 
    /**
47
 
     * Applies field parser, if defined
48
 
     *
49
 
     * @method parse
50
 
     * @param value {Object} Original value.
51
 
     * @param field {Object} Field.
52
 
     * @return {Object} Type-converted value.
53
 
     */
54
 
    parse: function(value, field) {
55
 
        if(field.parser) {
56
 
            var parser = (LANG.isFunction(field.parser)) ?
57
 
            field.parser : Y.Parsers[field.parser+''];
58
 
            if(parser) {
59
 
                value = parser.call(this, value);
60
 
            }
61
 
            else {
62
 
                Y.log("Could not find parser for field " + Y.dump(field), "warn", "dataschema-json");
63
 
            }
64
 
        }
65
 
        return value;
66
 
    }
67
 
};
68
 
 
69
 
Y.namespace("DataSchema").Base = SchemaBase;
70
 
Y.namespace("Parsers");
71
 
 
72
 
 
73
 
 
74
 
}, '3.2.0' ,{requires:['base']});