1 dojo.provide("calitha.collections.StringBuilder"); 2 3 dojo.declare("calitha.collections.StringBuilder", null, 4 { 5 6 constructor: function(str) 7 { 8 this._buffer = new Array(); 9 if (str != null) 10 { 11 this.append(str); 12 } 13 } 14 , 15 append: function(str) 16 { 17 this._buffer[this._buffer.length] = str; 18 return this; 19 } 20 , 21 appendln: function(str) 22 { 23 this.append(str); 24 this.append("\n"); 25 return this; 26 } 27 , 28 prepend: function(str) 29 { 30 this._buffer.splice(0, 0, str); 31 return this; 32 } 33 , 34 prependln: function(str) 35 { 36 this._buffer.splice(0, 0, str, "\n"); 37 return this; 38 } 39 , 40 toString: function() 41 { 42 return this._buffer.join(""); 43 } 44 45 }); 46