public abstract class AbstractPrinter extends Object implements Printer
Printer
interface.Modifier and Type | Class and Description |
---|---|
static class |
AbstractPrinter.Level
The "importance levels" that a
Printer supports. |
Constructor and Description |
---|
AbstractPrinter() |
Modifier and Type | Method and Description |
---|---|
void |
debug(String pattern,
Object... arguments)
Prints a debug message.
|
AbstractPrinter |
discard(AbstractPrinter.Level level)
Creates and returns an
AbstractPrinter which discards all messages of the given level, and
forwards all other messages to this AbstractWriter . |
AbstractPrinter |
discard(EnumSet<AbstractPrinter.Level> levels)
Creates and returns an
AbstractPrinter which discards all messages of the given levels, and
forwards all other messages to this AbstractWriter . |
AbstractPrinter |
discardDebug(ConsumerWhichThrows<? super String,? extends RuntimeException> debugConsumer) |
AbstractPrinter |
discardError(ConsumerWhichThrows<? super String,? extends RuntimeException> errorConsumer) |
AbstractPrinter |
discardInfo(ConsumerWhichThrows<? super String,? extends RuntimeException> infoConsumer) |
AbstractPrinter |
discardVerbose(ConsumerWhichThrows<? super String,? extends RuntimeException> verboseConsumer) |
AbstractPrinter |
discardWarn(ConsumerWhichThrows<? super String,? extends RuntimeException> warnConsumer) |
void |
error(String pattern,
Object... arguments)
Prints an error condition.
|
void |
error(String message,
Throwable t)
Prints an error condition.
|
void |
error(String pattern,
Throwable t,
Object... arguments)
Prints an error condition.
|
static AbstractPrinter |
fromPrinter(Printer printer)
Wraps a
Printer as an AbstractPrinter . |
static AbstractPrinter |
getContextPrinter()
Returns the context printer for this thread.
|
void |
info(String pattern,
Object... arguments)
Prints an informative ("normal") message.
|
AbstractPrinter |
redirect(AbstractPrinter.Level level,
ConsumerWhichThrows<? super String,? extends RuntimeException> messageConsumer)
Creates and returns an
AbstractPrinter which sends all non-null messages of the given
levelto the given messageConsumer, and forwards all other messages to this AbstractWriter . |
AbstractPrinter |
redirect(AbstractPrinter.Level level,
Writer writer)
Creates and returns an
AbstractPrinter which writes messages of the given levelto the given
writer, and forwards all other messages to this AbstractWriter . |
AbstractPrinter |
redirect(EnumSet<AbstractPrinter.Level> levels,
ConsumerWhichThrows<? super String,? extends RuntimeException> messageConsumer)
Creates and returns an
AbstractPrinter which sends all non-null messages of the given
levelsto the given messageConsumer, and forwards all other messages to this AbstractWriter . |
AbstractPrinter |
redirect(EnumSet<AbstractPrinter.Level> levels,
Writer writer)
Creates and returns an
AbstractPrinter which writes messages of the given levelsto the given
writer, and forwards all other messages to this AbstractWriter . |
AbstractPrinter |
redirectDebug(ConsumerWhichThrows<? super String,? extends RuntimeException> debugConsumer) |
AbstractPrinter |
redirectDebug(Writer w) |
AbstractPrinter |
redirectError(ConsumerWhichThrows<? super String,? extends RuntimeException> errorConsumer) |
AbstractPrinter |
redirectError(Writer w) |
AbstractPrinter |
redirectInfo(ConsumerWhichThrows<? super String,? extends RuntimeException> infoConsumer) |
AbstractPrinter |
redirectInfo(Writer w) |
AbstractPrinter |
redirectVerbose(ConsumerWhichThrows<? super String,? extends RuntimeException> verboseConsumer) |
AbstractPrinter |
redirectVerbose(Writer w) |
AbstractPrinter |
redirectWarn(ConsumerWhichThrows<? super String,? extends RuntimeException> warnConsumer) |
AbstractPrinter |
redirectWarn(Writer w) |
void |
run(Runnable runnable)
Sets the current thread's context printer to
this , runs the runnable, and eventually
restores the original context printer. |
<EX extends Throwable> |
run(RunnableWhichThrows<EX> runnable)
Sets the current thread's context printer to
this , runs the runnable, and eventually
restores the original context printer. |
void |
verbose(String pattern,
Object... arguments)
Prints a verbose message.
|
void |
warn(String pattern,
Object... arguments)
Prints a warning condition.
|
public static AbstractPrinter getContextPrinter()
Printers.DEFAULT_PRINTER
.
Notice that it is (intentionally) not possible to explicitly set the current thread's context
printer; instead you would use run(Runnable)
.
public static AbstractPrinter fromPrinter(Printer printer)
Printer
as an AbstractPrinter
.public void error(@Nullable String message, @Nullable Throwable t)
Printer
public void error(String pattern, @Nullable Throwable t, Object... arguments)
Printer
error
in interface Printer
Format.format(Object)
public void error(String pattern, Object... arguments)
Printer
error
in interface Printer
Format.format(Object)
public void warn(String pattern, Object... arguments)
Printer
warn
in interface Printer
Format.format(Object)
public void info(String pattern, Object... arguments)
Printer
info
in interface Printer
Format.format(Object)
public void verbose(String pattern, Object... arguments)
Printer
verbose
in interface Printer
Format.format(Object)
public void debug(String pattern, Object... arguments)
Printer
debug
in interface Printer
Format.format(Object)
public final void run(Runnable runnable)
this
, runs the runnable, and eventually
restores the original context printer.public final <EX extends Throwable> void run(RunnableWhichThrows<EX> runnable) throws EX extends Throwable
this
, runs the runnable, and eventually
restores the original context printer.EX extends Throwable
public final AbstractPrinter redirectError(@Nullable Writer w)
redirect(Level, Writer)
public final AbstractPrinter redirectWarn(@Nullable Writer w)
redirect(Level, Writer)
public final AbstractPrinter redirectInfo(@Nullable Writer w)
redirect(Level, Writer)
public final AbstractPrinter redirectVerbose(@Nullable Writer w)
redirect(Level, Writer)
public final AbstractPrinter redirectDebug(@Nullable Writer w)
redirect(Level, Writer)
public final AbstractPrinter redirect(@Nullable AbstractPrinter.Level level, @Nullable Writer writer)
AbstractPrinter
which writes messages of the given levelto the given
writer, and forwards all other messages to this
AbstractWriter
.
Iff level == null ||
writer == null
, then this
object is
returned instead.
public final AbstractPrinter redirect(@Nullable EnumSet<AbstractPrinter.Level> levels, @Nullable Writer writer)
AbstractPrinter
which writes messages of the given levelsto the given
writer, and forwards all other messages to this
AbstractWriter
.
Iff levels == null ||
levels.isEmpty() ||
writer ==
null
, then this
object is returned instead.
public final AbstractPrinter redirectError(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> errorConsumer)
redirect(Level, ConsumerWhichThrows)
public final AbstractPrinter redirectWarn(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> warnConsumer)
redirect(Level, ConsumerWhichThrows)
public final AbstractPrinter redirectInfo(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> infoConsumer)
redirect(Level, ConsumerWhichThrows)
public final AbstractPrinter redirectVerbose(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> verboseConsumer)
redirect(Level, ConsumerWhichThrows)
public final AbstractPrinter redirectDebug(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> debugConsumer)
redirect(Level, ConsumerWhichThrows)
public final AbstractPrinter redirect(@Nullable AbstractPrinter.Level level, @Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> messageConsumer)
AbstractPrinter
which sends all non-null
messages of the given
levelto the given messageConsumer, and forwards all other messages to this
AbstractWriter
.
Iff level == null ||
messageConsumer == null
, then this
object is
returned instead.
public final AbstractPrinter redirect(@Nullable EnumSet<AbstractPrinter.Level> levels, @Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> messageConsumer)
AbstractPrinter
which sends all non-null
messages of the given
levelsto the given messageConsumer, and forwards all other messages to this
AbstractWriter
.
Iff levels == null ||
levels.isEmpty() ||
messageConsumer
== null
, then this
object is returned instead.
public final AbstractPrinter discardError(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> errorConsumer)
discard(Level)
public final AbstractPrinter discardWarn(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> warnConsumer)
discard(Level)
public final AbstractPrinter discardInfo(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> infoConsumer)
discard(Level)
public final AbstractPrinter discardVerbose(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> verboseConsumer)
discard(Level)
public final AbstractPrinter discardDebug(@Nullable ConsumerWhichThrows<? super String,? extends RuntimeException> debugConsumer)
discard(Level)
public final AbstractPrinter discard(@Nullable AbstractPrinter.Level level)
AbstractPrinter
which discards all messages of the given level, and
forwards all other messages to this
AbstractWriter
.
Iff level == null
, then this
object is returned instead.
public final AbstractPrinter discard(@Nullable EnumSet<AbstractPrinter.Level> levels)
AbstractPrinter
which discards all messages of the given levels, and
forwards all other messages to this
AbstractWriter
.
Iff levels == null ||
levels.isEmpty()
, then this
object is
returned instead.
Copyright © 2018 Arno Unkrig. All rights reserved.