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