Package eu.bandm.tools.message
Class OffsetIndicationPrinter
java.lang.Object
eu.bandm.tools.message.OffsetIndicationPrinter
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<String>>
public class OffsetIndicationPrinter
extends Object
implements MessageReceiver<SimpleMessage<String>>
Prints textual representations of all received messages to an
output stream.
Assumes that the DocumentId is the one line document contents (i.e. a string contents which is its own identifier), and indicates the error position by indentation in a second line below the printed contents.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The number of the leftmost column.protected final PrintWriter
The target of all print activities.protected boolean
Whether to emit a leading newline. -
Constructor Summary
ConstructorsConstructorDescriptionPrints toSystem.err
, using default encoding.Prints to a newly createdPrintWriter
to theOutputStream
provided.Prints to thePrintWriter
provided. -
Method Summary
Modifier and TypeMethodDescriptionvoid
receive
(SimpleMessage<String> message) Print the message to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Field Details
-
out
The target of all print activities. -
prependNewline
protected boolean prependNewlineWhether to emit a leading newline. Defaults to false, but can be set by class derivationnew OffsetIndicationPrinter(){{prependNewline = true;}}
-
leftMostColumnNumber
protected int leftMostColumnNumberThe number of the leftmost column. Defaults to 1. Can be set by class derivationnew OffsetIndicationPrinter(){{leftMostColumnNumber = 0;}}
-
-
Constructor Details
-
OffsetIndicationPrinter
public OffsetIndicationPrinter()Prints toSystem.err
, using default encoding. -
OffsetIndicationPrinter
Prints to a newly createdPrintWriter
to theOutputStream
provided. Consequently using a default encoding.- Parameters:
os
- where to print to
-
OffsetIndicationPrinter
Prints to thePrintWriter
provided. So the encoding can be set explicitly.- Parameters:
out
- where to print to
-
-
Method Details
-
receive
Print the message to the output stream.First the id is printed (= the document contents), then a newline, an indentation, a caret symbol, the message kind and the message text. After each printed message the output stream is
flushed
explicitly.
In situations where stderr is likely to be contaminated with other output, not terminated by newline, an extra newline can be prepended to make the indentation of the caret visually correct.- Specified by:
receive
in interfaceMessageReceiver<SimpleMessage<String>>
- Parameters:
message
- the message to receive.
-