Class TracePrintStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
de.christofreichardt.diagnosis.io.IndentablePrintStream
de.christofreichardt.diagnosis.io.TracePrintStream
- All Implemented Interfaces:
Indentable,Closeable,Flushable,Appendable,AutoCloseable
This is the main implementation of an indentable PrintStream. This stream uses a thread map to retrieve the current stack size
and computes the extend of the indentation accordingly.
- Author:
- Christof Reichardt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intnumber of spaces that should used per indentationprotected static final String[]string array that contains the indent stringsstatic final intindicates the maximum number of indentationsprotected final AbstractThreadMapprovides access to the tracing contexts indexed by thread objectsFields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance by passing aNullOutputStreamto the base class.TracePrintStream(OutputStream out, AbstractThreadMap threadMap) Creates a new instance of TracePrintStream by passing the given OutputStream to the underlying PrintStream. -
Method Summary
Modifier and TypeMethodDescriptionprintfIndentln(String format, Object... args) A convenience method to print an indented string onto the stream using the specified format string and the given arguments.Prints an indented string.Prints an indented string together with a line feed.Prints only the current indentation.Methods inherited from class java.io.PrintStream
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, writeBytesMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
MAX_INDENT_NUMBER
public static final int MAX_INDENT_NUMBERindicates the maximum number of indentations- See Also:
-
INDENT_CHAR_NUMBER
public static final int INDENT_CHAR_NUMBERnumber of spaces that should used per indentation- See Also:
-
INDENT_STRING
string array that contains the indent strings -
threadMap
provides access to the tracing contexts indexed by thread objects
-
-
Constructor Details
-
TracePrintStream
public TracePrintStream()Creates a new instance by passing aNullOutputStreamto the base class. -
TracePrintStream
Creates a new instance of TracePrintStream by passing the given OutputStream to the underlying PrintStream. The threadMap will be needed to determine the current stack size and hence the indentation level.- Parameters:
out- the underlying OutputStreamthreadMap- to compute the indentation level
-
-
Method Details
-
printIndent
Description copied from interface:IndentablePrints an indented string.- Specified by:
printIndentin interfaceIndentable- Specified by:
printIndentin classIndentablePrintStream- Parameters:
s- the string to be printed- Returns:
- the indentable stream itself
-
printIndentln
Description copied from interface:IndentablePrints an indented string together with a line feed.- Specified by:
printIndentlnin interfaceIndentable- Specified by:
printIndentlnin classIndentablePrintStream- Parameters:
s- the string to be printed- Returns:
- the indentable stream itself
-
printIndentString
Description copied from interface:IndentablePrints only the current indentation.- Specified by:
printIndentStringin interfaceIndentable- Specified by:
printIndentStringin classIndentablePrintStream- Returns:
- the indentable stream itself
-
printfIndentln
Description copied from interface:IndentableA convenience method to print an indented string onto the stream using the specified format string and the given arguments.- Specified by:
printfIndentlnin interfaceIndentable- Specified by:
printfIndentlnin classIndentablePrintStream- Parameters:
format- the format stringargs- the to be printed arguments- Returns:
- the indentable stream itself
-