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.system.Environment;
027:
028: /**
029: * The root element of a structure which belongs to a JacShow record.
030: *
031: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
032: * @version 1.0
033: */
034: public class JacShowRootElement extends RootElement {
035: private static final int SEQUENCE_COUNT = 4;
036: private static long[] pd;
037: private static long[] da;
038: private static long[] db;
039: private static int[] cb;
040:
041: /**
042: * Creates a new jacshow root structure element.
043: *
044: * @param env the environment
045: * @param children the child structure elements
046: */
047: public JacShowRootElement(Environment env,
048: StructureElement[] children) {
049: super (env, children);
050: calculatePerformanceValues();
051: }
052:
053: private void calculatePerformanceValues() {
054: StructureElement[] seChildren = getChildren("jacareto.struct.Sequence");
055:
056: pd = new long[SEQUENCE_COUNT];
057: da = new long[SEQUENCE_COUNT];
058: db = new long[SEQUENCE_COUNT];
059: cb = new int[SEQUENCE_COUNT];
060:
061: for (int i = 0; i < seChildren.length; i++) {
062: Sequence element = (Sequence) seChildren[i];
063: String elementName = element.getName();
064: int index = -1;
065:
066: if (elementName.startsWith("M1 ")) {
067: index = 0;
068: } else if (elementName.startsWith("M2 ")) {
069: index = 1;
070: } else if (elementName.startsWith("M3 ")) {
071: index = 2;
072: } else if (elementName.startsWith("M4 ")) {
073: index = 3;
074: }
075:
076: if (index >= 0) {
077: pd[index] = element.getPerformanceDuration();
078: da[index] = element.getDurationA();
079: db[index] = element.getDurationB();
080: cb[index] = element.getCountB();
081: }
082: }
083: }
084:
085: public long getPerformanceDuration(int i) {
086: return pd[i];
087: }
088:
089: public long getDurationA(int i) {
090: return da[i];
091: }
092:
093: public long getDurationB(int i) {
094: return db[i];
095: }
096:
097: public int getCountB(int i) {
098: return cb[i];
099: }
100:
101: /**
102: * Clones the element.
103: *
104: * @return DOCUMENT ME!
105: */
106: public Object clone() {
107: StructureElement[] clonedChildren = getClonedChildren();
108:
109: return new JacShowRootElement(env, clonedChildren);
110: }
111: }
|