01: /*
02: * Created on Mar 10, 2004
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.collection;
08:
09: import java.util.HashMap;
10:
11: import org.xdev.base.util.Tools;
12: import org.xdev.base.xssl.XSSLAction;
13: import org.xdev.base.xssl.XSSLReturn;
14:
15: /**
16: * @author AYegorov
17: *
18: * To change the template for this generated type comment go to
19: * Window>Preferences>Java>Code Generation>Code and Comments
20: */
21: public class CollectionFormatter extends XSSLCollectionIterator {
22: private StringBuffer buffer = new StringBuffer();
23:
24: /**
25: * @param id
26: */
27: public CollectionFormatter(String id) {
28: super (id);
29: // XXX Auto-generated constructor stub
30: }
31:
32: /**
33: * @param id
34: * @param properties
35: */
36: public CollectionFormatter(String id, HashMap properties) {
37: super (id, properties);
38: // XXX Auto-generated constructor stub
39: }
40:
41: /* (non-Javadoc)
42: * @see org.xdev.base.xssl.collection.XSSLCollectionIterator#processCollectionItem(org.xdev.base.xssl.XSSLAction)
43: */
44: protected Object processCollectionItem(XSSLAction item, Object next)
45: throws Exception {
46: if (item.execute(this )) {
47: buffer.append(Tools.replaceString(((XSSLReturn) item)
48: .getObjectValue().toString(), "@value@",
49: next != null ? next.toString() : ""));
50:
51: buffer.append(this .getProperty("delimiter"));
52: }
53:
54: return item;
55: }
56:
57: public Object getObjectValue() {
58: return buffer.length() > 0 ? buffer.substring(0, buffer
59: .length() - 1) : "";
60: }
61:
62: public void commit() throws Exception {
63: this .buffer.setLength(0);
64: }
65: }
|