View Javadoc

1   /*
2    * Created on Sep 22, 2005. Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the "License"); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
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  }