01: /*
02: * Created on Jul 17, 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.XSSLAction;
13: import org.xdev.base.xssl.XSSLComponent;
14: import org.xdev.base.xssl.XSSLActionIterator;
15:
16: /**
17: * @author AYegorov
18: *
19: * To change the template for this generated type comment go to
20: * Window>Preferences>Java>Code Generation>Code and Comments
21: */
22: public class TextTranslate extends XSSLActionIterator {
23: private String translationValue = "";
24: private String translatedValue = "";
25:
26: private boolean translated = false;
27:
28: /**
29: * @param id
30: */
31: public TextTranslate(String id) {
32: super (id);
33: // TODO Auto-generated constructor stub
34: }
35:
36: /**
37: * @param id
38: * @param properties
39: */
40: public TextTranslate(String id, HashMap properties) {
41: super (id, properties);
42: // TODO Auto-generated constructor stub
43: }
44:
45: /* (non-Javadoc)
46: * @see org.xdev.base.transaction.AbstractTransactionIterator#invoke(org.xdev.base.transaction.AbstractTransactionComponent)
47: */
48: protected void invoke(XSSLAction component) throws Exception {
49: String target = component.getProperty("target");
50: String source = component.getProperty("source");
51: if (this .getBooleanProperty("ignore-case")) {
52: source = source.toLowerCase();
53: this .translationValue = this .translationValue.toLowerCase();
54: }
55:
56: if (this .translationValue.equals(source)) {
57: this .translatedValue = target;
58: this .breakIteration();
59: }
60: if (this .isLastElement()) {
61: this .translatedValue = this .translationValue;
62: }
63: }
64:
65: protected void set() throws Exception {
66: this .translationValue = this .getProperty("value");
67:
68: }
69:
70: public Object getObjectValue() {
71: return this.translatedValue;
72: }
73: }
|