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.parse.RecordTokenizerState;
028: import jacareto.system.Environment;
029:
030: import java.util.Vector;
031:
032: /**
033: * The mouse pointer has been moved over hyperlinks. A structure element can parse a part of a
034: * record.
035: *
036: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
037: * @version 1.0
038: */
039: public class MouseMotionOverHyperlinks extends StructureElement {
040: /**
041: * Creates a new "mouse motion over components" structure element.
042: *
043: * @param env the environment
044: * @param children the child structure elements
045: */
046: public MouseMotionOverHyperlinks(Environment env,
047: StructureElement[] children) {
048: super (env, children);
049: }
050:
051: /**
052: * Parses a record which is tokenized by the given record tokenizer.
053: *
054: * @param env DOCUMENT ME!
055: * @param recordTokenizer the record tokenizer
056: *
057: * @return a structure element, or <code>null</code> if this class cannot parse the record at
058: * the current position
059: */
060: public static StructureElement parse(Environment env,
061: RecordTokenizer recordTokenizer) {
062: StructureElement result = null;
063: Vector addedChildren = new Vector(5, 5);
064:
065: RecordTokenizerState rtState = recordTokenizer.saveState();
066:
067: try {
068: int hMotions = 0;
069: boolean found = true;
070:
071: while (found) {
072: found = false;
073:
074: MouseMotionOverHyperlink hMotion = (MouseMotionOverHyperlink) MouseMotionOverHyperlink
075: .parse(env, recordTokenizer);
076:
077: if (hMotion != null) {
078: addedChildren.add(hMotion);
079: found = true;
080: hMotions++;
081: }
082:
083: MouseMotion motion = (MouseMotion) MouseMotion.parse(
084: env, recordTokenizer);
085:
086: if (motion != null) {
087: addedChildren.add(motion);
088: found = true;
089: }
090: }
091:
092: if (hMotions >= 1) {
093: result = new MouseMotionOverHyperlinks(env,
094: vectorToArray(addedChildren));
095: } else {
096: throw new Exception();
097: }
098: } catch (Throwable t) {
099: recordTokenizer.restoreState(rtState);
100: }
101:
102: return result;
103: }
104:
105: /**
106: * Returns the name of the element.
107: *
108: * @return the name
109: */
110: public String getElementName() {
111: return language
112: .getString("Structures.MouseMotionOverHyperlinks.Name");
113: }
114:
115: /**
116: * Returns a description of the element.
117: *
118: * @return the description
119: */
120: public String getElementDescription() {
121: return language
122: .getString("Structures.MouseMotionOverHyperlinks.Description");
123: }
124:
125: /**
126: * Returns a String which describes the content of the element shortly.
127: *
128: * @return a string with a short description of the element
129: */
130: public String toShortString() {
131: return getElementName();
132: }
133:
134: /**
135: * Clones the element.
136: *
137: * @return DOCUMENT ME!
138: */
139: public Object clone() {
140: StructureElement[] clonedChildren = getClonedChildren();
141:
142: return new MouseMotionOverHyperlinks(env, clonedChildren);
143: }
144: }
|