/*
作者：蓝 (lanxikun@sina.com)
时间：2005-3-18
版本：0.1
*/

/*
一个字符串处理类，字符串格式为：as|sd|12|334|rd
提供add()方法和remove()方法，用于向字符串中添加子项，add时保证了不重复
*/

//要求s的格式为竖线分隔，前后没有竖线
function ParamString(s)
{
	this.str=s;
}

//在字符串中增加一个子串
ParamString.prototype.add=function(s)
{
	a=this.str.split("|");
	b=this.str;
	result=false;
	for(i=0;i<a.length;i++){
		if(a[i]==s) result=true;
	}
	if(!result)
		b+="|"+s;
	if(b.charAt(0)=="|")b=b.substr(1);
	this.str=b;
}

//在字符串中移除一个子串
ParamString.prototype.remove=function(s)
{
	a=this.str.split("|");
	b="";
	for(i=0;i<a.length;i++){
		if(a[i]!=s)
			b+="|"+a[i];
	}
	if(b.charAt(0)=="|")b=b.substr(1);
	this.str=b;
}

//返回字符串参数
ParamString.prototype.toString=function()
{
	return this.str;
}