package com.cidat.proclets;

public class ListJoinProclet implements Proclet {
	String listValName;
	String loopValName;
	String loopNumberExpr;
	String addExpr;
	String separatorExpr;

	public ListJoinProclet(String listValName, String loopValName,
			String loopNumberExpr, String addExpr, String separatorExpr) {
		this.listValName = listValName;
		this.loopValName = loopValName;
		this.loopNumberExpr = loopNumberExpr;
		this.addExpr = addExpr;
		this.separatorExpr = separatorExpr;
	}

	public void process(ProcletServiceData sd) throws ProcletException {
		StringBuffer list = new StringBuffer();
		int end = Integer.valueOf(sd.evalExpr(this.loopNumberExpr)).intValue();

		for (int n = 0; n < end; n++) {
			sd.setVal(this.loopValName, "" + n);
			list.append(sd.evalExpr(this.addExpr));
			if ((n < end - 1) && (this.separatorExpr != null))
				list.append(sd.evalExpr(this.separatorExpr));
		}
		sd.setVal(this.listValName, list.toString());
	}
}

/*
 * Location:
 * D:\svn\ejie\q53.trunk\codigo\q53\q53ItourbaskWar\WebContent\WEB-INF\
 * lib\proclets_wl81.jar Qualified Name: com.cidat.proclets.ListJoinProclet
 * JD-Core Version: 0.6.0
 */