org.stringtemplate.v4
Interface STWriter

All Known Implementing Classes:
AutoIndentWriter, NoIndentWriter

public interface STWriter

Generic StringTemplate output writer filter. Literals and the elements of expressions are emitted via write(). Separators are emitted via writeSeparator() because they must be handled specially when wrapping lines (we don't want to wrap in between an element and it's separator).


Field Summary
static int NO_WRAP
           
 
Method Summary
 int index()
          Return the absolute char index into the output of the char we're about to write.
 void popAnchorPoint()
           
 java.lang.String popIndentation()
           
 void pushAnchorPoint()
           
 void pushIndentation(java.lang.String indent)
           
 void setLineWidth(int lineWidth)
           
 int write(java.lang.String str)
          Write the string and return how many actual chars were written.
 int write(java.lang.String str, java.lang.String wrap)
          Same as write, but wrap lines using the indicated string as the wrap character (such as "\n").
 int writeSeparator(java.lang.String str)
          Write a separator.
 int writeWrap(java.lang.String wrap)
          Because we evaluate ST instance by invoking exec() again, we can't pass options in.
 

Field Detail

NO_WRAP

static final int NO_WRAP
See Also:
Constant Field Values
Method Detail

pushIndentation

void pushIndentation(java.lang.String indent)

popIndentation

java.lang.String popIndentation()

pushAnchorPoint

void pushAnchorPoint()

popAnchorPoint

void popAnchorPoint()

setLineWidth

void setLineWidth(int lineWidth)

write

int write(java.lang.String str)
          throws java.io.IOException
Write the string and return how many actual chars were written. With autoindentation and wrapping, more chars than length(str) can be emitted. No wrapping is done.

Throws:
java.io.IOException

write

int write(java.lang.String str,
          java.lang.String wrap)
          throws java.io.IOException
Same as write, but wrap lines using the indicated string as the wrap character (such as "\n").

Throws:
java.io.IOException

writeWrap

int writeWrap(java.lang.String wrap)
              throws java.io.IOException
Because we evaluate ST instance by invoking exec() again, we can't pass options in. So the WRITE instruction of an applied template (such as when we wrap in between template applications like ]}; wrap>) we need to write the wrap string before calling exec(). We expose just like for the separator. See Interpreter.writeObject where it checks for ST instance. If POJO, writePOJO passes wrap to STWriter's write(String str, String wrap) method. Can't pass to exec().

Throws:
java.io.IOException

writeSeparator

int writeSeparator(java.lang.String str)
                   throws java.io.IOException
Write a separator. Same as write() except that a \n cannot be inserted before emitting a separator.

Throws:
java.io.IOException

index

int index()
Return the absolute char index into the output of the char we're about to write. Returns 0 if no char written yet.



Copyright © 2011. All Rights Reserved.