Skip to content

Commit

Permalink
IndentedWriter - Return this from settings; tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Sep 2, 2023
1 parent 29f3632 commit b785f1b
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.io.StringWriter ;

/** IndentLineBuffer is a buffer that records an indent level
/** IndentLineBuffer is a buffer that records an indent level
* and uses that to insert a prefix at each line.
* It can also insert line numbers at the beginning of lines.
*/
Expand All @@ -29,22 +29,22 @@ public class IndentedLineBuffer extends IndentedWriter
{
StringWriter sw ;
public IndentedLineBuffer() { this(false) ; }

public IndentedLineBuffer(boolean withLineNumbers)
{
super(new StringWriter(), withLineNumbers) ;
sw = (StringWriter)super.out ;
}

public StringBuffer getBuffer() { return sw.getBuffer(); }

public String asString() { return sw.toString() ; }
@Override
public String toString() { return asString() ; }

// Names more usually used for a buffer.
public void append(String fmt, Object... args) { printf(fmt, args) ; }
public void append(char ch) { print(ch) ;}

public void clear() { sw.getBuffer().setLength(0) ; }
}
Loading

0 comments on commit b785f1b

Please sign in to comment.