- java.lang.Object
-
- de.carne.mcd.jvmdecoder.classfile.PrintBuffer
-
- All Implemented Interfaces:
Printable
public final class PrintBuffer extends java.lang.Object implements Printable
Utility class used for exchanging ClassPrinter output.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePrintBuffer.PrinterFunctional interface for defining the actual print output.
-
Constructor Summary
Constructors Constructor Description PrintBuffer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrintBufferappend(java.lang.String token)Appends a token to the buffer using default style.PrintBufferappend(java.lang.String token, PrintBuffer.Printer printer)Appends a token to the buffer using the given style.booleanisEmpty()Checks whether this buffer instance is empty (and produces no output).voidprint(ClassPrinter out, ClassContext context)Prints this instance.static voidprint(java.lang.String token, ClassPrinter out, ClassContext context)Prints token using default style.static voidprintKeyword(java.lang.String token, ClassPrinter out, ClassContext context)Prints token using keyword style.java.lang.StringtoString()
-
-
-
Method Detail
-
print
public static void print(java.lang.String token, ClassPrinter out, ClassContext context) throws java.io.IOExceptionPrints 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.IOExceptionPrints 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:
trueif 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:PrintablePrints this instance.- Specified by:
printin interfacePrintable- 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:
toStringin classjava.lang.Object
-
-