public class SourcePrinter extends Object
Modifier and Type | Method and Description |
---|---|
void |
duplicateIndent()
Adds an indent to the top of the stack that is a copy of the current top indent.
|
Position |
getCursor()
Return the current cursor position (line, column) in the source printer buffer.
|
String |
getSource()
Deprecated.
use toString()
|
SourcePrinter |
indent()
Add the default indentation to the current indentation and push it on the indentation stack.
|
SourcePrinter |
indentWithAlignTo(int column)
Add to the current indentation until it is reaches "column" and push it on the indentation stack.
|
String |
normalizeEolInTextBlock(String content)
Changes all EOL characters in "content" to the EOL character this SourcePrinter is using.
|
SourcePrinter |
print(String arg)
Append the source string passed as argument to the buffer.
|
SourcePrinter |
println()
Append a newline to the buffer.
|
SourcePrinter |
println(String arg)
Append the source string passed as argument to the buffer, then append a newline.
|
void |
reindentToPreviousLevel()
Set the top-most indent to the column the cursor was before the last
reindentWithAlignToCursor() call. |
void |
reindentWithAlignToCursor()
Set the top-most indent to the column the cursor is currently in, can be undone with
reindentToPreviousLevel() . |
String |
toString() |
SourcePrinter |
unindent()
Pop the last indentation of the indentation stack.
|
public SourcePrinter indent()
public SourcePrinter indentWithAlignTo(int column)
public SourcePrinter unindent()
public SourcePrinter print(String arg)
The source line to be printed should not contain newline/carriage-return characters;
use println(String)
to automatically append a newline at the end of the source string.
If the source line passed as argument contains newline/carriage-return characters would
impredictably affect a correct computation of the current getCursor()
position.
arg
- source line to be printed (should not contain newline/carriage-return characters)println(String)
public SourcePrinter println(String arg)
The source line to be printed should not contain newline/carriage-return characters.
If the source line passed as argument contains newline/carriage-return characters would
impredictably affect a correct computation of the current getCursor()
position.
arg
- source line to be printed (should not contain newline/carriage-return characters)public SourcePrinter println()
public Position getCursor()
Please notice in order to guarantee a correct computation of the cursor position,
this printer expect the contracts of the methods print(String)
and println(String)
has been respected through all method calls, meaning the source string passed as argument to those method
calls did not contain newline/carriage-return characters.
@Deprecated public String getSource()
public String toString()
public String normalizeEolInTextBlock(String content)
public void reindentWithAlignToCursor()
reindentToPreviousLevel()
. Does not actually output anything.public void reindentToPreviousLevel()
reindentWithAlignToCursor()
call.
Does not actually output anything.public void duplicateIndent()
Copyright © 2007–2022. All rights reserved.