public interface STWriter
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 it's separator).
Modifier and Type | Field and Description |
---|---|
static int |
NO_WRAP |
Modifier and Type | Method and Description |
---|---|
int |
index()
Return the absolute char index into the output of the char
we're about to write.
|
void |
popAnchorPoint() |
String |
popIndentation() |
void |
pushAnchorPoint() |
void |
pushIndentation(String indent) |
void |
setLineWidth(int lineWidth) |
int |
write(String str)
Write the string and return how many actual characters were written.
|
int |
write(String str,
String wrap)
Same as write, but wrap lines using the indicated string as the
wrap character (such as
"\n" ). |
int |
writeSeparator(String str)
Write a separator.
|
int |
writeWrap(String wrap)
Because we evaluate ST instance by invoking
Interpreter.exec(STWriter, InstanceScope) again, we can't pass options in. |
static final int NO_WRAP
void pushIndentation(String indent)
String popIndentation()
void pushAnchorPoint()
void popAnchorPoint()
void setLineWidth(int lineWidth)
int write(String str) throws IOException
str.length()
can be emitted. No wrapping is done.IOException
int write(String str, String wrap) throws IOException
"\n"
).IOException
int writeWrap(String wrap) throws IOException
Interpreter.exec(STWriter, InstanceScope)
again, we can't pass options in.
So the Bytecode.INSTR_WRITE
instruction of an applied template
(such as when we wrap in between template applications like
<data:{v|[<v>]}; wrap>
) we need to write the wrap
string
before calling Interpreter.exec(org.stringtemplate.v4.STWriter, org.stringtemplate.v4.InstanceScope)
. We expose just like for the
separator. See Interpreter.writeObject(org.stringtemplate.v4.STWriter, org.stringtemplate.v4.InstanceScope, java.lang.Object, java.lang.String[])
where it checks for ST
instance. If POJO, Interpreter.writePOJO(org.stringtemplate.v4.STWriter, org.stringtemplate.v4.InstanceScope, java.lang.Object, java.lang.String[])
passes wrap
to
write(String str, String wrap)
. Can't pass to
Interpreter.exec(org.stringtemplate.v4.STWriter, org.stringtemplate.v4.InstanceScope)
.IOException
int writeSeparator(String str) throws IOException
write(String)
except that a "\n"
cannot be inserted before emitting a separator.IOException
int index()
Copyright © 2024. All rights reserved.