Package com.mackenziehigh.sexpr.util
Class StringPrinter
java.lang.Object
com.mackenziehigh.sexpr.util.StringPrinter
Instances of this class simplify the creation of indented text.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUse this method in order to make subsequent output less indented.int
Use this method in order to retrieve the current indentation level.Use this method in order to make subsequent output more indented.output()
Use this method to retrieve the output string.Use this method to print a value to the output string.Use this method to print a formatted value to the output string.This method prints the string representation of an iterable.println()
Use this method to print a newline to the output string.Use this method to print a value and a newline to the output string.Use this method to print a series of values to the output string, one per line.setIndent
(int value) Use this method in order to make subsequent output more or less indented.toString()
-
Constructor Details
-
StringPrinter
public StringPrinter(int capacity, int tabsize) Sole Constructor.- Parameters:
capacity
- is the expected capacity of the output string.tabsize
- is the number of spaces per indentation level.
-
-
Method Details
-
increment
Use this method in order to make subsequent output more indented.- Returns:
- this.
-
decrement
Use this method in order to make subsequent output less indented.- Returns:
- this.
-
setIndent
Use this method in order to make subsequent output more or less indented.- Parameters:
value
- is the new indentation level.- Returns:
- this.
-
getIndent
public int getIndent()Use this method in order to retrieve the current indentation level.- Returns:
- the current level of indentation.
-
print
Use this method to print a value to the output string.- Parameters:
value
- is the value to print.- Returns:
- this.
-
println
Use this method to print a newline to the output string.- Returns:
- this.
-
println
Use this method to print a value and a newline to the output string.- Parameters:
value
- is the value to print.- Returns:
- this.
-
printf
Use this method to print a formatted value to the output string.- Parameters:
format
- is the format specifier string.args
- are the values to substitute into the format string.- Returns:
- this.
-
printlns
Use this method to print a series of values to the output string, one per line.- Parameters:
values
- is the value to print.- Returns:
- this.
-
printList
public StringPrinter printList(Iterable<?> iterable, String prefix, String separator, String suffix) This method prints the string representation of an iterable.- Parameters:
iterable
- is the iterable itself.prefix
- is a string to prepend onto the result.separator
- is the substring used to separate elements in the result.suffix
- is a string to append onto the result.- Returns:
- this.
-
output
Use this method to retrieve the output string.- Returns:
- the generated output.
-
toString
-