/*
 * 模拟java的 StringBuffer
 */
function StringBuffer(value){
	this._Strings = new Array(value||'') ;
}
StringBuffer.prototype.append = function(value){
	if(value)
		this._Strings.push(value) ;
}
StringBuffer.prototype.toString = function(){
	return this._Strings.join('') ;
}
StringBuffer.prototype.length = function(){
	var str = this.toString();
	if(str)return str.length;
	else return 0;
}
StringBuffer.prototype.clear = function(){
	this._Strings.splice(0,this._Strings.length);
}
StringBuffer.prototype.reverse=function(){
	this._Strings.reverse();
}
/*
 * 替换 &, <, > 为&amp;&lt;&gt
 */
StringBuffer.prototype.escapeHtml=function(){
	var div = document.createElement('div');
  var text = document.createTextNode(this.toString());
  div.appendChild(text);
  return div.innerHTML;
}
/*
 * 替换 &amp;&lt;&gt 为&, <, >
 */
StringBuffer.prototype.unescapeHtml=function(){
	var div = document.createElement('div');
	var str = this.toString();
  div.innerHTML = str.replace(/<\/?[^>]+>/gi, '');
  return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
}
