Source Code Cross Referenced for XSSLActionIterator.java in  » XML » activexml » org » xdev » base » xssl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » activexml » org.xdev.base.xssl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Jul 14, 2003
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package org.xdev.base.xssl;
008:
009:        import java.util.ArrayList;
010:        import java.util.HashMap;
011:        import java.util.List;
012:        import java.util.Observer;
013:
014:        import org.xdev.base.xssl.collection.XSSLCollectionIterator;
015:        import org.xdev.base.xssl.manage.TransactionReturn;
016:
017:        /**
018:         * @author AYegorov
019:         *
020:         * To change the template for this generated type comment go to
021:         * Window>Preferences>Java>Code Generation>Code and Comments
022:         */
023:        public abstract class XSSLActionIterator extends XSSLReturn {
024:            public static final String EXECUTE_FLAG = "execute";
025:            public static final String CLONE_FLAG = "clone";
026:            public static final String STEP_FLAG = "step-into";
027:
028:            public static final int ITERATOR_START_EVENT = 19;
029:            public static final int ITERATOR_END_EVENT = 20;
030:            public static final int ITERATOR_BROKEN_EVENT = 21;
031:            public static final int ITERATOR_ACTION_START_EVENT = 22;
032:            public static final int ITERATOR_ACTION_END_EVENT = 23;
033:            public static final int ITERATOR_ACTION_INVOKE_EVENT = 24;
034:            public static final int ITERATOR_ACTION_EVENT = 25;
035:
036:            protected int iterationIndex = 0;
037:            protected int iterationSize = 0;
038:
039:            private boolean iterating = false;
040:
041:            /**
042:             * @param id
043:             */
044:            public XSSLActionIterator(String id) {
045:                super (id);
046:                // TODO Auto-generated constructor stub
047:            }
048:
049:            /**
050:             * @param id
051:             * @param properties
052:             */
053:            public XSSLActionIterator(String id, HashMap properties) {
054:                super (id, properties);
055:                // TODO Auto-generated constructor stub
056:            }
057:
058:            /* (non-Javadoc)
059:             * @see com.reliant.b2b.templates.TemplateAbstractAction#process()
060:             */
061:            protected void invoke() throws Exception {
062:                Exception thrown = null;
063:                try {
064:                    super .init();
065:
066:                    this .iterating = true;
067:                    this .setProperty("is-loop-broken", "false");
068:
069:                    XSSLAction c = null;
070:                    Object obj = null;
071:
072:                    this .issueTrigger(XSSLActionIterator.ITERATOR_START_EVENT);
073:
074:                    List children = this .getElements(false);
075:
076:                    for (this .setIterationIndex(); this .iterationIndex < (this .iterationSize = this 
077:                            .getCount())
078:                            && !this .isLoopBroken(); this .iterationIndex++) {
079:                        boolean lastElement = (this .iterationIndex < this .iterationSize - 1);
080:
081:                        //c = (XSSLAction)this.getElement(this.iterationIndex);
082:
083:                        c = (XSSLAction) children.get(this .iterationIndex);
084:
085:                        if (!c.isBroken()) {
086:                            this 
087:                                    .issueTrigger(
088:                                            XSSLActionIterator.ITERATOR_ACTION_EVENT,
089:                                            c);
090:
091:                            this .logDebug("Iterating with element: " + c);
092:
093:                            boolean doExecution = c
094:                                    .getBooleanProperty(XSSLActionIterator.EXECUTE_FLAG)
095:                                    || !c
096:                                            .hasProperty(XSSLActionIterator.EXECUTE_FLAG);
097:
098:                            this .logDebug("Element " + c
099:                                    + " will be executed: " + doExecution);
100:
101:                            if (doExecution) {
102:
103:                                if (this 
104:                                        .getBooleanProperty(XSSLActionIterator.CLONE_FLAG)
105:                                        | c
106:                                                .getBooleanProperty(XSSLActionIterator.CLONE_FLAG)) {
107:                                    c = (XSSLAction) c.newInstance(this 
108:                                            .getRoot(), this 
109:                                            .getParentComponent());
110:
111:                                    this .logDebug("Component " + c
112:                                            + " was cloned and now has parent "
113:                                            + c.getParentComponent()
114:                                            + " and root " + c.getRoot());
115:                                }
116:
117:                                this .logDebug("Executing element: " + c);
118:
119:                                obj = this .executeIteratingElement(c,
120:                                        lastElement);
121:                            }
122:
123:                            if (c instanceof  XSSLCollectionIterator
124:                                    && c
125:                                            .getBooleanProperty(XSSLActionIterator.STEP_FLAG)) {
126:                                List list = (List) ((XSSLCollectionIterator) c)
127:                                        .getObjectValue();
128:
129:                                int size = list.size();
130:
131:                                for (int i = 0; i < size; i++) {
132:                                    this .invoke((XSSLAction) list.get(i));
133:                                }
134:                            } else {
135:                                this .invoke(c);
136:                            }
137:                            this 
138:                                    .issueTrigger(
139:                                            XSSLActionIterator.ITERATOR_ACTION_INVOKE_EVENT,
140:                                            c);
141:
142:                            c = null;
143:                        }
144:                    }
145:                    this .issueTrigger(XSSLActionIterator.ITERATOR_END_EVENT);
146:
147:                    super .invoke();
148:                } catch (Exception ex) {
149:                    thrown = ex;
150:                } finally {
151:                    this .iterating = false;
152:                    if (thrown != null) {
153:                        throw thrown;
154:                    }
155:                }
156:            }
157:
158:            protected Object executeIteratingElement(XSSLAction c,
159:                    boolean lastElement) throws Exception {
160:                Object obj = null;
161:
162:                this .issueTrigger(
163:                        XSSLActionIterator.ITERATOR_ACTION_START_EVENT, c);
164:                if (!c.execute(this )
165:                        && this .getBooleanProperty("strict-iteration")) {
166:                    throw new Exception(
167:                            "Transaction Iteration was interrupted due to malformed Transaction execution...");
168:                }
169:                this .setProperty("!iterator-last-element-flag", String
170:                        .valueOf(lastElement));
171:                this .setProperty("iterator-last-element-flag", String
172:                        .valueOf(!lastElement));
173:                if (c instanceof  XReference) {
174:                    obj = ((XReference) c).getObjectValue();
175:                    if (obj instanceof  XSSLAction) {
176:                        c = (XSSLAction) obj;
177:                    }
178:                }
179:
180:                this .issueTrigger(XSSLActionIterator.ITERATOR_ACTION_END_EVENT,
181:                        c);
182:
183:                return obj;
184:            }
185:
186:            public void reset() {
187:                super .reset();
188:                this .iterating = false;
189:            }
190:
191:            protected int setIterationIndex() {
192:                return (this .iterationIndex = 0);
193:            }
194:
195:            private boolean isIterating() {
196:                return this .iterating;
197:            }
198:
199:            protected boolean isLastElement() {
200:                boolean flag = false;
201:                if (iterationSize != 0) {
202:                    flag = !(iterationIndex < iterationSize - 1);
203:                }
204:
205:                return flag;
206:            }
207:
208:            protected void breakIteration() {
209:                this .setProperty("is-loop-broken", "true");
210:
211:                try {
212:                    this .issueTrigger(XSSLActionIterator.ITERATOR_BROKEN_EVENT);
213:                } catch (Exception ex) {
214:                    this .logError(ex);
215:                }
216:            }
217:
218:            private boolean isLoopBroken() {
219:                return this .getBooleanProperty("is-loop-broken");
220:            }
221:
222:            abstract protected void invoke(XSSLAction component)
223:                    throws Exception;
224:
225:            public Object getObjectValue() {
226:                return null;
227:            }
228:
229:            /**
230:             * @return Returns the iterationIndex.
231:             */
232:            public int getIterationIndex() {
233:                return iterationIndex;
234:            }
235:
236:            /**
237:             * @param iterationIndex The iterationIndex to set.
238:             */
239:            public void setIterationIndex(int iterationIndex) {
240:                this .iterationIndex = iterationIndex;
241:            }
242:
243:            /**
244:             * @return Returns the iterationSize.
245:             */
246:            public int getIterationSize() {
247:                return iterationSize;
248:            }
249:
250:            /**
251:             * @param iterationSize The iterationSize to set.
252:             */
253:            public void setIterationSize(int iterationSize) {
254:                this .iterationSize = iterationSize;
255:            }
256:
257:            /**
258:             * @param iterating The iterating to set.
259:             */
260:            public void setIterating(boolean iterating) {
261:                this .iterating = iterating;
262:            }
263:
264:            /**
265:             * @return Returns the iTERATOR_ACTION_END_EVENT.
266:             */
267:            public static int getITERATOR_ACTION_END_EVENT() {
268:                return ITERATOR_ACTION_END_EVENT;
269:            }
270:
271:            /**
272:             * @return Returns the iTERATOR_ACTION_EVENT.
273:             */
274:            public static int getITERATOR_ACTION_EVENT() {
275:                return ITERATOR_ACTION_EVENT;
276:            }
277:
278:            /**
279:             * @return Returns the iTERATOR_ACTION_INVOKE_EVENT.
280:             */
281:            public static int getITERATOR_ACTION_INVOKE_EVENT() {
282:                return ITERATOR_ACTION_INVOKE_EVENT;
283:            }
284:
285:            /**
286:             * @return Returns the iTERATOR_ACTION_START_EVENT.
287:             */
288:            public static int getITERATOR_ACTION_START_EVENT() {
289:                return ITERATOR_ACTION_START_EVENT;
290:            }
291:
292:            /**
293:             * @return Returns the iTERATOR_BROKEN_EVENT.
294:             */
295:            public static int getITERATOR_BROKEN_EVENT() {
296:                return ITERATOR_BROKEN_EVENT;
297:            }
298:
299:            /**
300:             * @return Returns the iTERATOR_END_EVENT.
301:             */
302:            public static int getITERATOR_END_EVENT() {
303:                return ITERATOR_END_EVENT;
304:            }
305:
306:            /**
307:             * @return Returns the iTERATOR_START_EVENT.
308:             */
309:            public static int getITERATOR_START_EVENT() {
310:                return ITERATOR_START_EVENT;
311:            }
312:
313:            public void breakExecution() {
314:                super .breakExecution();
315:
316:                this .breakIteration();
317:            }
318:
319:            public void setExecuteElements(boolean flag) {
320:                this.setProperty(XSSLActionIterator.EXECUTE_FLAG, String
321:                        .valueOf(flag));
322:            }
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.