1
2
3
4
5
6
7
8
9
10 package com.sri.emo.wizard.expressoimpl;
11
12 import com.jcorporate.expresso.core.controller.ControllerException;
13 import com.jcorporate.expresso.core.controller.Transition;
14 import com.sri.emo.wizard.Link;
15 import com.sri.emo.wizard.WizardException;
16
17 import java.io.*;
18
19
20 /***
21 * Link bridge between Wizard links and Expresso Transitions.
22 *
23 * @author Michael Rimov
24 */
25 public class ExpressoLink implements Link, Serializable, Externalizable, Cloneable {
26 /***
27 *
28 */
29 private static final long serialVersionUID = 1L;
30 /***
31 * The wrapped Transition.
32 */
33 private Transition link;
34
35 /***
36 * Do not use except for Externalization.
37 */
38 public ExpressoLink() {
39 link = null;
40 }
41
42 /***
43 * Construction takes an Expresso Transition as its
44 *
45 * @param t the Expresso Transition.
46 */
47 public ExpressoLink(final Transition t) {
48 link = t;
49 }
50
51 /***
52 * Returns the transition for the link.
53 *
54 * @return Transition.
55 */
56 public Transition getTransition() {
57 return link;
58 }
59
60 public String getLink() throws WizardException {
61 try {
62 return getTransition().getFullUrl();
63 } catch (ControllerException ex) {
64 throw new WizardException("Error generating link", ex);
65 }
66 }
67
68
69 public void writeExternal(final ObjectOutput out) throws IOException {
70 out.writeObject(link);
71 }
72
73 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
74 link = (Transition) in.readObject();
75 }
76
77 public Object clone() throws CloneNotSupportedException {
78 ExpressoLink el = (ExpressoLink) super.clone();
79 link = (Transition) link.clone();
80 return el;
81 }
82 }