1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor;
13
14 import sk.baka.ikslibs.modify.DOMChangeCollector;
15 import sk.baka.ikslibs.modify.IChangeCollector;
16 import sk.baka.xml.gene.CoordinatorInputKey;
17
18 /***
19 * <p>
20 * Able to preprocess the input of renderer and editor. It receives live source
21 * instances.
22 * </p>
23 * <p>
24 * First, {@link #process(IChangeCollector)} is called, to process GENE's output.
25 * Method's output (or the original source if it was modified instead of cloned)
26 * will be then passed to renderer and editor. When source document is changed,
27 * the changes are undoed by calling the {@link #undo(IChangeCollector)} method.
28 * This method is called ONLY if previous {@link #process(IChangeCollector)} call
29 * returned <code>null</code>. Then, changes are applied to the source and
30 * {@link #process(IChangeCollector)} is called again.
31 * </p>
32 * <p>
33 * The preprocessor instances may be thread-unsafe - one instance of
34 * preprocessor will never be used to process two sources at once.
35 * </p>
36 * <p>
37 * In case of {@link DOMChangeCollector}
38 * its source must not contain entities and CDATA nodes, and all adjacent text
39 * nodes must be merged together.
40 * </p>
41 * @author Martin Vysny
42 */
43 public interface IInputPreprocessor {
44 /***
45 * Initializes the preprocessor.
46 * @param input the input descriptor.
47 */
48 public void init(final CoordinatorInputKey input);
49 /***
50 * Processes the source.
51 * @param source the source instance to process.
52 * @return <code>null</code> if original source was modified, or a new
53 * source instance that will be passed to renderer and editor.
54 */
55 public IChangeCollector process(final IChangeCollector source);
56 /***
57 * Undoes the changes made to the source by previous
58 * {@link #process(IChangeCollector)} call.
59 * @param source undo changes on this source.
60 */
61 public void undo(final IChangeCollector source);
62 }