01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10: package de.uka.ilkd.key.util.pp;
11:
12: /**
13: * The backend for a {@link Layouter}. An object satisfying this
14: * interface can act as a receiver for the layed out text produced by
15: * a {@link Layouter}. A <code>Backend</code> must also provide the
16: * maximum line width available through the {@link #lineWidth()}
17: * method. Finally, it is responsible for calculating (with {@link
18: * #measure(String)} the amount of space it actually needs to print a
19: * given string. For instance, if strings printed through a {@link
20: * Layouter} are actually known to be in HTML, {@link
21: * #measure(String)} can return the size of the text, not including
22: * markup.
23: *
24: * <P>There is currently no provision to handle proportional fonts,
25: * and there might never be.
26: *
27: * @author Martin Giese
28: * @see Layouter
29: *
30: */
31:
32: public interface Backend {
33: /** Append a String <code>s</code> to the output. <code>s</code>
34: * contains no newlines. */
35: void print(String s) throws java.io.IOException;
36:
37: /** Start a new line. */
38: void newLine() throws java.io.IOException;
39:
40: /** Closes this backend */
41: void close() throws java.io.IOException;
42:
43: /** Flushes any buffered output */
44: void flush() throws java.io.IOException;
45:
46: /** Gets called to record a <code>mark()</code> call in the input. */
47: void mark(Object o);
48:
49: /** Returns the available space per line */
50: int lineWidth();
51:
52: /** Returns the space required to print the String <code>s</code> */
53: int measure(String s);
54:
55: }
|