public class AutoIndentWriter extends java.lang.Object implements StringTemplateWriter
Modifier and Type | Field and Description |
---|---|
protected int[] |
anchors
Stack of integer anchors (char positions in line); avoid Integer
creation overhead.
|
protected int |
anchors_sp |
protected boolean |
atStartOfLine |
protected int |
charPosition
Track char position in the line (later we can think about tabs).
|
protected int |
charPositionOfStartOfExpr |
protected java.util.List |
indents
stack of indents; use List as it's much faster than Stack.
|
protected int |
lineWidth |
protected java.lang.String |
newline
\n or \r\n?
|
protected java.io.Writer |
out |
NO_WRAP
Constructor and Description |
---|
AutoIndentWriter(java.io.Writer out) |
AutoIndentWriter(java.io.Writer out,
java.lang.String newline) |
Modifier and Type | Method and Description |
---|---|
int |
getIndentationWidth() |
protected java.lang.StringBuffer |
getIndentString(int spaces) |
int |
indent() |
int |
indent(int spaces) |
void |
popAnchorPoint() |
java.lang.String |
popIndentation() |
void |
pushAnchorPoint() |
void |
pushIndentation(java.lang.String indent)
Push even blank (null) indents as they are like scopes; must
be able to pop them back off stack.
|
void |
setLineWidth(int lineWidth) |
int |
write(java.lang.String str)
Write out a string literal or attribute expression or expression element.
|
int |
write(java.lang.String str,
java.lang.String wrap)
Write out a string literal or attribute expression or expression element.
|
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
|
protected java.util.List indents
protected int[] anchors
protected int anchors_sp
protected java.lang.String newline
protected java.io.Writer out
protected boolean atStartOfLine
protected int charPosition
protected int lineWidth
protected int charPositionOfStartOfExpr
public AutoIndentWriter(java.io.Writer out, java.lang.String newline)
public AutoIndentWriter(java.io.Writer out)
public void setLineWidth(int lineWidth)
setLineWidth
in interface StringTemplateWriter
public void pushIndentation(java.lang.String indent)
pushIndentation
in interface StringTemplateWriter
public java.lang.String popIndentation()
popIndentation
in interface StringTemplateWriter
public void pushAnchorPoint()
pushAnchorPoint
in interface StringTemplateWriter
public void popAnchorPoint()
popAnchorPoint
in interface StringTemplateWriter
public int getIndentationWidth()
public int write(java.lang.String str) throws java.io.IOException
write
in interface StringTemplateWriter
java.io.IOException
public int writeSeparator(java.lang.String str) throws java.io.IOException
StringTemplateWriter
writeSeparator
in interface StringTemplateWriter
java.io.IOException
public int write(java.lang.String str, java.lang.String wrap) throws java.io.IOException
write
in interface StringTemplateWriter
java.io.IOException
public int writeWrapSeparator(java.lang.String wrap) throws java.io.IOException
StringTemplateWriter
writeWrapSeparator
in interface StringTemplateWriter
java.io.IOException
public int indent() throws java.io.IOException
java.io.IOException
public int indent(int spaces) throws java.io.IOException
java.io.IOException
protected java.lang.StringBuffer getIndentString(int spaces)
Copyright © 2006-2023 Terence Parr