Debian Codegraph @

dojox/wire/TextAdapter.js

raw symbols SCIP
1 dojo.provide("dojox.wire.TextAdapter");
2
3 dojo.require("dojox.wire.CompositeWire");
4
5 dojo.declare("dojox.wire.TextAdapter", dojox.wire.CompositeWire, {
6 // summary:
7 // A composite Wire for a concatenated text
8 // description:
9 // This class has multiple child Wires for text segment values.
10 // Wires in 'segments' property are used to get text segments and
11 // values are concatenated with an optional delimiter string specified
12 // to 'delimiter' property.
13
14 _wireClass: "dojox.wire.TextAdapter",
15
16 constructor: function(/*Object*/ args){
17 // summary:
18 // Initialize properties
19 // description:
20 // If array elements specified in 'segments' are not Wires, Wires
21 // are created from them as arguments, with 'parent' property set
22 // to this Wire instance.
23 // args:
24 // Arguments to initialize properties:
25 //
26 // - segments: An array containing child Wires for text segment values
27 // - delimiter: A delimiter string
28 this._initializeChildren(this.segments);
29 if(!this.delimiter){
30 this.delimiter = "";
31 }
32 },
33
34 _getValue: function(/*Object||Array*/object){
35 // summary:
36 // Return a concatenated text
37 // description:
38 // This method calls getValue() method of the child Wires wuth
39 // 'object' argument and concatenate the values with 'delimiter'
40 // property to return.
41 // arg:
42 // A root object
43 // returns:
44 // A concatinated text
45 if(!object || !this.segments){
46 return object; //Object||Array
47 }
48
49 var text = "";
50 for(var i in this.segments){
51 var segment = this.segments[i].getValue(object);
52 text = this._addSegment(text, segment);
53 }
54 return text; //String
55 },
56
57 _setValue: function(/*Object||Array*/object, /*String*/value){
58 // summary:
59 // Not supported
60 throw new Error("Unsupported API: " + this._wireClass + "._setValue");
61 },
62
63 _addSegment: function(/*String*/text, /*String*/segment){
64 // summary:
65 // Return a concatenated text
66 // description:
67 // This method add a text segment specified to 'segment' argument
68 // to a base text specified to 'text', with 'delimiter' property.
69 // text:
70 // A base text
71 // segment:
72 // A text segment to add
73 // returns:
74 // A concatinated text
75 if(!segment){
76 return text; //String
77 }else if(!text){
78 return segment; //String
79 }else{
80 return text + this.delimiter + segment; //String
81 }
82 }
83 });