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.parse.RecordTokenizer;
027: import jacareto.record.ContainerEventRecordable;
028: import jacareto.system.Environment;
029:
030: import java.awt.event.ContainerEvent;
031:
032: /**
033: * This structure element stands for a sequence of adding components.
034: *
035: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
036: * @version 1.0
037: */
038: public class ComponentsAdded extends StructureElement {
039: /**
040: * Creates a new "components added" structure element.
041: *
042: * @param env the environment
043: * @param children the child structure elements
044: */
045: public ComponentsAdded(Environment env, StructureElement[] children) {
046: super (env, children);
047: }
048:
049: /**
050: * Parses a record which is tokenized by the given record tokenizer.
051: *
052: * @param env DOCUMENT ME!
053: * @param recordTokenizer the record tokenizer
054: *
055: * @return a structure element, or <code>null</code> if this class cannot parse the record at
056: * the current position
057: */
058: public static StructureElement parse(Environment env,
059: RecordTokenizer recordTokenizer) {
060: int counter = 0;
061: StructureElement element;
062: StructureElement result = null;
063:
064: try {
065: do {
066: element = recordTokenizer.get(counter);
067: counter++;
068: } while (element instanceof ContainerEventRecordable
069: && (((ContainerEventRecordable) element).getID() == ContainerEvent.COMPONENT_ADDED));
070:
071: // one too far
072: counter--;
073:
074: if (counter > 0) {
075: StructureElement[] children = new StructureElement[counter];
076:
077: for (int i = 0; i < counter; i++) {
078: children[i] = recordTokenizer.get(i);
079: }
080:
081: recordTokenizer.forward(counter);
082: result = new ComponentsAdded(env, children);
083: }
084: } catch (Exception e) {
085: ;
086: }
087:
088: return result;
089: }
090:
091: /**
092: * Returns the name of the element.
093: *
094: * @return the name
095: */
096: public String getElementName() {
097: return language.getString("Structures.ComponentsAdded.Name");
098: }
099:
100: /**
101: * Returns a description of the element.
102: *
103: * @return the description
104: */
105: public String getElementDescription() {
106: return language
107: .getString("Structures.ComponentsAdded.Description");
108: }
109:
110: /**
111: * Returns a String which describes the content of the element shortly.
112: *
113: * @return a string with a short description of the element
114: */
115: public String toShortString() {
116: return getElementName();
117: }
118:
119: /**
120: * Clones the element.
121: *
122: * @return DOCUMENT ME!
123: */
124: public Object clone() {
125: StructureElement[] clonedChildren = getClonedChildren();
126:
127: return new ComponentsAdded(env, clonedChildren);
128: }
129:
130: /**
131: * {@inheritDoc}
132: */
133: public boolean hasProcTime() {
134: return true;
135: }
136: }
|