public class MsgPrinter extends Object
Modifier and Type | Field and Description |
---|---|
private static int |
IS_EOS
Signals that the end-of-string was reached
|
private static int |
IS_NEWLINE
Signals that a newline was found
|
int |
lw
The line width to use
|
Constructor and Description |
---|
MsgPrinter(int linewidth)
Creates a new message printer with the specified line width and
with the default locale.
|
Modifier and Type | Method and Description |
---|---|
int |
getLineWidth()
Returns the line width that is used for formatting.
|
private int |
nextLineEnd(String str,
int from)
Returns the index of the last character of the next word, plus 1, or
IS_NEWLINE if a newline character is encountered before the next word,
or IS_EOS if the end of the string is ecnounterd before the next
word.
|
private int |
nextWord(String str,
int from)
Returns the position of the first character in the next word, starting
from 'from', if a newline is encountered first then the index of the
newline character plus 1 is returned.
|
void |
print(PrintWriter out,
int flind,
int ind,
String msg)
Formats the message to print in the current line width, by
breaking the message into lines between words.
|
void |
setLineWidth(int linewidth)
Sets the line width to the specified value.
|
public int lw
private static final int IS_NEWLINE
private static final int IS_EOS
public MsgPrinter(int linewidth)
linewidth
- The line width for which to format (in
characters)public int getLineWidth()
public void setLineWidth(int linewidth)
linewidth
- The new line width to use (in cahracters)public void print(PrintWriter out, int flind, int ind, String msg)
out
- Where to print the message.flind
- The indentation for the first line.ind
- The indentation for the other lines.msg
- The message to format and print.private int nextLineEnd(String str, int from)
Non-whitespace characters are defined as in the Character.isWhitespace method (that method is used).
str
- The string to parsefrom
- The index of the first position to search fromprivate int nextWord(String str, int from)
Non-whitespace characters are defined as in the Character.isWhitespace method (that method is used).
str
- The string to parsefrom
- The index where to start parsingCopyright © 2017 Open Microscopy Environment