Generic StringTemplate output writer filter. Literals and the elements of expressions are emitted via #write(String). Separators are emitted via #writeSeparator(String) because they must be handled specially when wrapping lines (we don't want to wrap in between an element and
| 40 | |
| 41 | |
| 42 | public interface STWriter { |
| 43 | int NO_WRAP = -1; |
| 44 | void pushIndentation(String indent); |
| 45 | String popIndentation(); |
| 46 | void pushAnchorPoint(); |
| 47 | void popAnchorPoint(); |
| 48 | void setLineWidth(int lineWidth); |
| 49 | |
| 50 | /** Write the string and return how many actual characters were written. |
| 51 | * With auto-indentation and wrapping, more chars than {@code str.length()} |
| 52 | * can be emitted. No wrapping is done. |
| 53 | */ |
| 54 | int write(String str) throws IOException; |
| 55 | |
| 56 | /** Same as write, but wrap lines using the indicated string as the |
| 57 | * wrap character (such as {@code "\n"}). |
| 58 | */ |
| 59 | int write(String str, String wrap) throws IOException; |
| 60 | |
| 61 | /** |
| 62 | * Because we evaluate ST instance by invoking |
| 63 | * {@link Interpreter#exec(STWriter, InstanceScope)} again, we can't pass options in. |
| 64 | * So the {@link Bytecode#INSTR_WRITE} instruction of an applied template |
| 65 | * (such as when we wrap in between template applications like |
| 66 | * {@code <data:{v|[<v>]}; wrap>}) we need to write the {@code wrap} string |
| 67 | * before calling {@link Interpreter#exec}. We expose just like for the |
| 68 | * separator. See {@link Interpreter#writeObject} where it checks for ST |
| 69 | * instance. If POJO, {@link Interpreter#writePOJO} passes {@code wrap} to |
| 70 | * {@link STWriter#write(String str, String wrap)}. Can't pass to |
| 71 | * {@link Interpreter#exec}. |
| 72 | */ |
| 73 | int writeWrap(String wrap) throws IOException; |
| 74 | |
| 75 | /** Write a separator. Same as {@link #write(String)} except that a {@code "\n"} |
| 76 | * cannot be inserted before emitting a separator. |
| 77 | */ |
| 78 | int writeSeparator(String str) throws IOException; |
| 79 | |
| 80 | /** Return the absolute char index into the output of the char |
| 81 | * we're about to write. Returns 0 if no char written yet. |
| 82 | */ |
| 83 | int index(); |
| 84 | } |
nothing calls this directly
no outgoing calls
no test coverage detected