Class StringPrinter

java.lang.Object
com.mackenziehigh.sexpr.util.StringPrinter

public final class StringPrinter extends Object
Instances of this class simplify the creation of indented text.
  • 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

      public StringPrinter increment()
      Use this method in order to make subsequent output more indented.
      Returns:
      this.
    • decrement

      public StringPrinter decrement()
      Use this method in order to make subsequent output less indented.
      Returns:
      this.
    • setIndent

      public StringPrinter setIndent(int value)
      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

      public StringPrinter print(Object value)
      Use this method to print a value to the output string.
      Parameters:
      value - is the value to print.
      Returns:
      this.
    • println

      public StringPrinter println()
      Use this method to print a newline to the output string.
      Returns:
      this.
    • println

      public StringPrinter println(Object value)
      Use this method to print a value and a newline to the output string.
      Parameters:
      value - is the value to print.
      Returns:
      this.
    • printf

      public StringPrinter printf(String format, Object... args)
      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

      public StringPrinter printlns(Iterable<?> values)
      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

      public String output()
      Use this method to retrieve the output string.
      Returns:
      the generated output.
    • toString

      public String toString()
      Overrides:
      toString in class Object