1 //字符串拼接方法
2 StringBuffer = function(){
3 this._strings_ = new Array();
4 if (typeof StringBuffer._initialized == "undefined") {
5 StringBuffer.prototype.append = function(str){
6 if(typeof str == 'string')
7 this._strings_.push(str);
8 }
9 StringBuffer.prototype.appendFormat = function(str){
10 var args = arguments;
11 str = str.replace(/\{(\d+)\}/g, function(m, i){
12 return args[++i];
13 })
14 this._strings_.push(str);
15 }
16 StringBuffer.prototype.toString = function(){
17 if(typeof arguments[0]=='string')
18 return this._strings_.join(arguments[0]);
19 return this._strings_.join("");
20 }
21 StringBuffer.prototype.clear = function(){
22 this._strings_ = [];
23 }
24 StringBuffer._initialized = true;
25 }
26 };