public class MsgPrintStream extends java.lang.Object implements MsgPrintStream_ifc
System.err.println("Source of message - short message; some additional " + information);This is a form which may be proper outside this class too. One should inform about the source of the message, then what's happen, then some more information. If one uses a semicolon as separator, it's able to present such messages for example in an Excel sheet.
System.outto the message system: The
LogMessageinterface needs a number to identify the message, the
MsgDispatcherneeds numbers to dispatch. If any identification string is used the first time, a number is created automatically. If the same start text is used a second one (especially if an output was invoked a second time), the start text is identified and the same number is used. One can sort messages with that number.
"Source - second division" "Source-specification - second division" "Source-second division"the message dispatcher can deal with ranges.
setMsgIdents(MsgText_ifc). This can be used in conclusion with
MsgConfig.setMsgDispaching(MsgDispatcher, String)to set the dispatching of this message.
|Modifier and Type||Field and Description|
This class is used for all outputs to the
Version, history and license.
|Constructor and Description|
|Modifier and Type||Method and Description|
Returns the PrintStream which converts and redirects the output String to the given LogMessage output.
Creates a group with the given text and the given ident number range.
Sets all associations between a message identification text to its ident number or to its number range.
protected final java.io.OutputStream outStream
PrintStreamAdapterwhich are not gathered by the overridden methods of PrintStream. There should not be such methods. Therefore the write-methods is not called. But the outStream should not be empty.
public static final int version
PrintStreamAdapter#append(CharSequence)because it is invoked in the
PrintStreamand should overridden to output the text. Note that one of the core methods of PrintStream is write(...) but that is private.
PrintStreamAdapter#print(String)does not dispatch the text directly but does append it to an internal line buffer till an newline "\n" is detected. It is because the super method append(CharSequence) calls this method. A PrintStream can be referred as
Appendableand the output can be done with ref.append("start - string;").append(parameter).append("\n") too!
setMsgGroupIdent(String, int, int)to handle message dispatching with known or probably texts.
#getPrintStreamLog()to set System.setOut(...) and System.setErr(...).
public MsgPrintStream(LogMessage logOut, int identStart, int sizeNoGroup, int sizeGroup)
MsgPrintStream myPrintStream = new MsgPrintStream(myMsgDispatcher, 10000, 5000, 100);In this example the range from 1 to 9999 is used for messages which have a defined number outside of this class. Any not numbered message is assigned in the range from 10000 till 149999 if it hasn't a group division, and in groups with the start numbers 15000, 15100 etc. (till 32699 there are 176 groups). Note that the range which can be used is the positive integer range from 0 to about 2000000000. It may be better able to read to have not so large numbers, but there are able to use. Note that you would not have so far different message texts.
logOut- The output where all messages are written after identifier number building. The
MsgDispatcherinstance is proper to use.
identStart- The first automatically created number used for non grouped message. Note that other messages have a known fixed number. Use a separate range in the positiv Integers range.
sizeNoGroup- number of the non grouped message identifiers. After this range the grouped messages starts. Use a high enough number such as 1000 or 10000 or more.
sizeGroup- Size of any group. Use a middle-high enough number such as 100 or 1000. There won't be more as 1000 several message texts in one group - usually.
protected void convertToMsg(java.lang.String pre, java.lang.CharSequence identString, java.lang.Object... args)
public java.io.PrintStream getPrintStreamLog(java.lang.String pre)
System.setOut(myMsgPrintStream.getPrintStreamLog("out.")); System.setErr(myMsgPrintStream.getPrintStreamLog("err."));Then any output to System.out.print... and System.err.print... will be redirected to the
LogMessageassociation given in the constructor of this class. One can create so much as necessary adapters. They uses the same association index between String and list. If the texts are given with
setMsgIdents(MsgText_ifc)without the prefix they produces the same message ident number. If the text are given with the prefix, the ident numbers are different. If the association between text and ident is not given before the first call of PrintStream.print..., different prefixes causes different message idents. In this kind for example System.out and System.err can be redirected to different message ident numbers though the output texts are the same.
System.setOut(systemPrintAdapter.getPrintStreamLog("out.")); //instead writing to console the PrintStream creates a message System.setErr(systemPrintAdapter.getPrintStreamLog("err.")); //and sends it to the message dispatcher.
public boolean setMsgGroupIdent(java.lang.String sIdent, int nrStart, int nrLast)
sIdent- The text till the exclusive " - " separation.
nrStart- The first number of the group
nrLast- The last number of the group.
public void setMsgIdents(MsgText_ifc src)
MsgText_ifc.MsgConfigItem.identTextit is associated to its number from
MsgText_ifc.MsgConfigItem.identNror its range to
MsgText_ifc.MsgConfigItem.identNrLaststored in this class (
idxGroupIdent). If any text is outputted via any
PrintStreamAdapter#printf(String, Object...)and this text has the same start text, this message ident number is taken. The ident numbers can be used to configure a message dispatcher independent but proper to this functionality from the same src. In this kind the messages with identification by text are dispatched accurately.