01: /*
02: * Created on Apr 8, 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.text;
08:
09: import java.util.HashMap;
10:
11: import org.xdev.base.xssl.XSSLReturn;
12:
13: /**
14: * @author AYegorov
15: *
16: * To change the template for this generated type comment go to
17: * Window>Preferences>Java>Code Generation>Code and Comments
18: */
19: public class TextInsert extends AbstractText {
20:
21: /**
22: * @param id
23: */
24: public TextInsert(String id) {
25: super (id);
26: // XXX Auto-generated constructor stub
27: }
28:
29: /**
30: * @param id
31: * @param properties
32: */
33: public TextInsert(String id, HashMap properties) {
34: super (id, properties);
35: }
36:
37: /* (non-Javadoc)
38: * @see org.xdev.base.xssl.text.AbstractText#processText(java.lang.String)
39: */
40: protected Object processText(String text) throws Exception {
41: XSSLReturn valueElm = (XSSLReturn) this .getElement(0);
42: XSSLReturn indexElm = (XSSLReturn) this .getElement(1);
43:
44: Object returnValue = null;
45:
46: if (valueElm.execute(this ) && indexElm.execute(this )) {
47: String value = valueElm.getObjectValue().toString();
48:
49: StringBuffer buffer = new StringBuffer(text);
50:
51: buffer.insert(Integer.parseInt(indexElm.getObjectValue()
52: .toString()), value);
53:
54: returnValue = buffer.toString();
55: }
56:
57: return returnValue;
58: }
59: }
|