Source Code Cross Referenced for Sequence.java in  » Testing » jacareto » jacareto » struct » 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 » Testing » jacareto » jacareto.struct 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.struct;
025:
026:        import jacareto.jacshow.SequenceEvent;
027:        import jacareto.jacshow.SequenceEventRecordable;
028:        import jacareto.parse.RecordTokenizer;
029:        import jacareto.parse.RecordTokenizerState;
030:        import jacareto.system.Environment;
031:
032:        import java.util.Vector;
033:
034:        /**
035:         * A structure for JacShow sequences.
036:         *
037:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
038:         * @version 1.0
039:         */
040:        public class Sequence extends StructureElement {
041:            /** The name of the sequence. */
042:            private String name;
043:
044:            /** The start time. */
045:            private long startTime;
046:
047:            /** The stop time. */
048:            private long stopTime;
049:
050:            /** The performance duration. */
051:            private long performanceDuration;
052:
053:            /** Special performance values */
054:            private long durationA;
055:
056:            /** Special performance values */
057:            private long durationB;
058:            private int countB;
059:
060:            /**
061:             * Creates a new sequence.
062:             *
063:             * @param env the environment
064:             * @param children the child structure elements
065:             */
066:            public Sequence(Environment env, StructureElement[] children) {
067:                super (env, children);
068:
069:                SequenceEventRecordable seStart = (SequenceEventRecordable) children[0];
070:                SequenceEventRecordable seStop = (SequenceEventRecordable) children[children.length - 1];
071:                name = seStart.getSequenceName();
072:                startTime = seStart.getWhen();
073:                stopTime = seStop.getWhen();
074:                calculatePerformanceValues();
075:            }
076:
077:            /**
078:             * Returns the name of the sequence
079:             *
080:             * @return the name as string
081:             */
082:            public String getName() {
083:                return name;
084:            }
085:
086:            /**
087:             * Returns the duration.
088:             *
089:             * @return the duration, in msec
090:             */
091:            public long getDuration() {
092:                return stopTime - startTime;
093:            }
094:
095:            /**
096:             * Calculates the performance duration.
097:             */
098:            private void calculatePerformanceValues() {
099:                // performance duration
100:                performanceDuration = getDuration();
101:                durationA = durationB = 0L;
102:                countB = 0;
103:
104:                StructureElement[] seChildren = getChildren("jacareto.struct.SequenceElement");
105:
106:                for (int i = 0; i < seChildren.length; i++) {
107:                    SequenceElement element = (SequenceElement) seChildren[i];
108:                    String elementName = element.getName();
109:
110:                    performanceDuration -= element.getDuration();
111:
112:                    if (elementName.startsWith("A ")) {
113:                        durationA += element.getDuration();
114:                    } else if (elementName.startsWith("B ")) {
115:                        durationB += element.getDuration();
116:                        countB++;
117:                    }
118:                }
119:            }
120:
121:            /**
122:             * Returns the performance duration
123:             *
124:             * @return the duration without the duration of children which are sequence elements.
125:             */
126:            public long getPerformanceDuration() {
127:                return performanceDuration;
128:            }
129:
130:            /**
131:             * Returns the duration A
132:             *
133:             * @return the duration
134:             */
135:            public long getDurationA() {
136:                return durationA;
137:            }
138:
139:            /**
140:             * Returns the duration B
141:             *
142:             * @return the duration
143:             */
144:            public long getDurationB() {
145:                return durationB;
146:            }
147:
148:            /**
149:             * Returns count B
150:             *
151:             * @return the count
152:             */
153:            public int getCountB() {
154:                return countB;
155:            }
156:
157:            /**
158:             * Parses a record which is tokenized by the given record tokenizer.
159:             *
160:             * @param env DOCUMENT ME!
161:             * @param recordTokenizer the record tokenizer
162:             *
163:             * @return a structure element, or <code>null</code> if this class cannot parse the record at
164:             *         the current position
165:             */
166:            public static StructureElement parse(Environment env,
167:                    RecordTokenizer recordTokenizer) {
168:                StructureElement result = null;
169:
170:                RecordTokenizerState rtState = recordTokenizer.saveState();
171:
172:                try {
173:                    SequenceEventRecordable seStart = (SequenceEventRecordable) recordTokenizer
174:                            .next();
175:
176:                    if (seStart.getID() != SequenceEvent.STARTED) {
177:                        throw new Exception();
178:                    }
179:
180:                    String startedName = seStart.getSequenceName();
181:
182:                    Vector elements = new Vector(20, 20);
183:                    elements.add(seStart);
184:
185:                    StructureElement next = null;
186:
187:                    do {
188:                        next = SequenceElement.parse(env, recordTokenizer);
189:
190:                        if (next == null) {
191:                            next = recordTokenizer.next();
192:                        }
193:
194:                        elements.add(next);
195:                    } while ((next != null)
196:                            && !(next instanceof  SequenceEventRecordable));
197:
198:                    if ((next != null)
199:                            && (next instanceof  SequenceEventRecordable)) {
200:                        SequenceEventRecordable seStop = (SequenceEventRecordable) next;
201:
202:                        if ((seStop.getID() != SequenceEvent.STOPPED)
203:                                || !seStop.getSequenceName()
204:                                        .equals(startedName)) {
205:                            throw new Exception();
206:                        }
207:                    } else {
208:                        throw new Exception();
209:                    }
210:
211:                    StructureElement[] children = vectorToArray(elements);
212:
213:                    result = new Sequence(env, children);
214:                } catch (Throwable t) {
215:                    recordTokenizer.restoreState(rtState);
216:                }
217:
218:                return result;
219:            }
220:
221:            /**
222:             * Returns the name of the element.
223:             *
224:             * @return the name
225:             */
226:            public String getElementName() {
227:                return language.getString("Structures.Sequence.Name");
228:            }
229:
230:            /**
231:             * Returns a description of the element.
232:             *
233:             * @return the description
234:             */
235:            public String getElementDescription() {
236:                return language.getString("Structures.Sequence.Description");
237:            }
238:
239:            /**
240:             * Returns a String which describes the content of the element shortly.
241:             *
242:             * @return a string with a short description of the element
243:             */
244:            public String toShortString() {
245:                return getName();
246:            }
247:
248:            /**
249:             * Clones the element.
250:             *
251:             * @return DOCUMENT ME!
252:             */
253:            public Object clone() {
254:                StructureElement[] clonedChildren = getClonedChildren();
255:
256:                return new Sequence(env, clonedChildren);
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.