Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / string / Builder.js @ 13

History | View | Annotate | Download (1.49 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.string.Builder"]){
9
dojo._hasResource["dojox.string.Builder"]=true;
10
dojo.provide("dojox.string.Builder");
11
dojox.string.Builder=function(_1){
12
var b="";
13
this.length=0;
14
this.append=function(s){
15
if(arguments.length>1){
16
var _2="",l=arguments.length;
17
switch(l){
18
case 9:
19
_2=""+arguments[8]+_2;
20
case 8:
21
_2=""+arguments[7]+_2;
22
case 7:
23
_2=""+arguments[6]+_2;
24
case 6:
25
_2=""+arguments[5]+_2;
26
case 5:
27
_2=""+arguments[4]+_2;
28
case 4:
29
_2=""+arguments[3]+_2;
30
case 3:
31
_2=""+arguments[2]+_2;
32
case 2:
33
b+=""+arguments[0]+arguments[1]+_2;
34
break;
35
default:
36
var i=0;
37
while(i<arguments.length){
38
_2+=arguments[i++];
39
}
40
b+=_2;
41
}
42
}else{
43
b+=s;
44
}
45
this.length=b.length;
46
return this;
47
};
48
this.concat=function(s){
49
return this.append.apply(this,arguments);
50
};
51
this.appendArray=function(_3){
52
return this.append.apply(this,_3);
53
};
54
this.clear=function(){
55
b="";
56
this.length=0;
57
return this;
58
};
59
this.replace=function(_4,_5){
60
b=b.replace(_4,_5);
61
this.length=b.length;
62
return this;
63
};
64
this.remove=function(_6,_7){
65
if(_7===undefined){
66
_7=b.length;
67
}
68
if(_7==0){
69
return this;
70
}
71
b=b.substr(0,_6)+b.substr(_6+_7);
72
this.length=b.length;
73
return this;
74
};
75
this.insert=function(_8,_9){
76
if(_8==0){
77
b=_9+b;
78
}else{
79
b=b.slice(0,_8)+_9+b.slice(_8);
80
}
81
this.length=b.length;
82
return this;
83
};
84
this.toString=function(){
85
return b;
86
};
87
if(_1){
88
this.append(_1);
89
}
90
};
91
}