Home | News | Wiki | About StringTemplate | Feedback | Support | Bugs


Latest version is 3.2.
Download now! »

Download
» Home
» Download
» News
»Using StringTemplate
» Documentation
» Wiki
» Articles
» File Sharing
» Code API
» Tech Support
»About StringTemplate
» What is it?
» Showcase
» Testimonials
» Software License
» Changes
»Feedback
»Credits
»Contact


Support StringTemplate, ANTLR Project by making a donation! Terence often pays for things like the antlr.org server, conference travel, and this site design (that alone cost US$1000). Buy him a beer and pizza remotely ;)

Search



StringTemplateWriter


org.antlr.stringtemplate
Interface StringTemplateWriter

All Known Implementing Classes:
AutoIndentWriter

public interface StringTemplateWriter

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
 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 writeWrapSeparator(java.lang.String wrap)
          Because we might need to wrap at a non-atomic string boundary (such as when we wrap in between template applications ]}; wrap>) we need to expose the wrap string writing just like for the separator.
 

Field Detail

NO_WRAP

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

pushIndentation

public void pushIndentation(java.lang.String indent)

popIndentation

public java.lang.String popIndentation()

pushAnchorPoint

public void pushAnchorPoint()

popAnchorPoint

public void popAnchorPoint()

setLineWidth

public void setLineWidth(int lineWidth)

write

public 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

public 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

writeWrapSeparator

public int writeWrapSeparator(java.lang.String wrap)
                       throws java.io.IOException
Because we might need to wrap at a non-atomic string boundary (such as when we wrap in between template applications ]}; wrap>) we need to expose the wrap string writing just like for the separator.

Throws:
java.io.IOException

writeSeparator

public 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