01: /*
02: * Created on Aug 5, 2003
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.ArrayList;
10: import java.util.HashMap;
11:
12: import org.xdev.base.xssl.*;
13:
14: /**
15: * @author AYegorov
16: *
17: * To change the template for this generated type comment go to
18: * Window>Preferences>Java>Code Generation>Code and Comments
19: */
20: public class TextContainsIndex extends AbstractText {
21:
22: /**
23: * @param id
24: */
25: public TextContainsIndex(String id) {
26: super (id);
27: // TODO Auto-generated constructor stub
28: }
29:
30: /**
31: * @param id
32: * @param properties
33: */
34: public TextContainsIndex(String id, HashMap properties) {
35: super (id, properties);
36: // TODO Auto-generated constructor stub
37: }
38:
39: /* (non-Javadoc)
40: * @see org.xdev.base.transaction.AbstractTransactionResult#getValue()
41: */
42: public Object processText(String text) throws Exception {
43: String index = "-1";
44: XSSLReturn part = (XSSLReturn) this .getElement(0);
45: if (part.execute(this )) {
46: Object value = part.getObjectValue();
47:
48: this .logDebug("Finding index of " + value + " in " + text);
49:
50: if (value != null) {
51: index = String
52: .valueOf((this .getBooleanProperty("last") ? text
53: .lastIndexOf(value.toString())
54: : text.indexOf(value.toString()))
55: + (this .getBooleanProperty("exclusive") ? value
56: .toString().length()
57: : 0));
58: }
59: }
60: part = null;
61:
62: this .logDebug("Text Index is: " + index);
63:
64: return index;
65: }
66:
67: }
|