Class PrintBuffer

  • All Implemented Interfaces:
    Printable

    public final class PrintBuffer
    extends java.lang.Object
    implements Printable
    Utility class used for exchanging ClassPrinter output.
    • Constructor Detail

      • PrintBuffer

        public PrintBuffer()
    • Method Detail

      • print

        public static void print​(java.lang.String token,
                                 ClassPrinter out,
                                 ClassContext context)
                          throws java.io.IOException
        Prints token using default style.
        Parameters:
        token - the token to print.
        out - the ClassPrinter to print to.
        context - the ClassContext to use for printing.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • printKeyword

        public static void printKeyword​(java.lang.String token,
                                        ClassPrinter out,
                                        ClassContext context)
                                 throws java.io.IOException
        Prints token using keyword style.
        Parameters:
        token - the token to print.
        out - the ClassPrinter to print to.
        context - the ClassContext to use for printing.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • isEmpty

        public boolean isEmpty()
        Checks whether this buffer instance is empty (and produces no output).
        Returns:
        true if this buffer instance is empty.
      • append

        public PrintBuffer append​(java.lang.String token)
        Appends a token to the buffer using default style.
        Parameters:
        token - the token to add.
        Returns:
        this instance for chaining.
      • append

        public PrintBuffer append​(java.lang.String token,
                                  PrintBuffer.Printer printer)
        Appends a token to the buffer using the given style.
        Parameters:
        token - the token to add.
        printer - the printer style to use.
        Returns:
        this instance for chaining.
      • print

        public void print​(ClassPrinter out,
                          ClassContext context)
                   throws java.io.IOException
        Description copied from interface: Printable
        Prints this instance.
        Specified by:
        print in interface Printable
        Parameters:
        out - the ClassPrinter instance to print to.
        context - the context of this print invocation.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object