public class SimpleMessage<D> extends Message
Message
class is only enhanced by a Location
, which points to
a document(/some documents), and a textual information text
,
and a list of arguments (=array of objects) which probably will be "sprintf"-ed
into the message.
SimpleMessage.Generator
should be preferred when possible.Modifier and Type | Class and Description |
---|---|
static class |
SimpleMessage.Generator<D>
Convenience factory class for creating
SimpleMessage s and
sending them immediately, --- all in one call. |
static class |
SimpleMessage.Ping<D>
Log message with not more informative content than "I am still alive".
|
Message.Kind
Modifier and Type | Field and Description |
---|---|
protected @Opt Location<D> |
location
Optional document position the message is related to.
|
protected @Opt String |
text
Contains the textual information of the message (maybe null).
|
Constructor and Description |
---|
SimpleMessage(Message.Kind k,
@Opt Exception e,
@Opt String t) |
SimpleMessage(Message.Kind k,
@Opt Exception e,
@Opt String t,
@Opt Locatable<D> l) |
SimpleMessage(SimpleMessage<D> msg)
return a clone.
|
Modifier and Type | Method and Description |
---|---|
static <D> SimpleMessage<D> |
error(Exception ex,
Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
error(Exception ex,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
error(Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
error(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
failure(Exception th)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
failure(Exception exception,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
failure(Locatable<D> loc,
Exception exception)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
failure(Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
failure(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
@Opt Location<D> |
getLocation() |
@Opt String |
getText() |
static <D> SimpleMessage<D> |
hint(Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
hint(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <X> Function<SimpleMessage<X>,SimpleMessage<X>> |
liftMapKind(Function<Message.Kind,Message.Kind> f)
Lift a function which operates on the
Kind part to one which
operates on the whole Message. |
static <D,E> Function<SimpleMessage<D>,SimpleMessage<E>> |
liftMapLocation(Function<Location<D>,Location<E>> f)
Constructs a function which maps SimpleMessages (never null to never null),
when a function
which maps their
Location (maybe null to maybe null) is given. |
static <X> Function<SimpleMessage<X>,SimpleMessage<X>> |
liftMapText(Function<String,String> f)
Lift a function which operates on the
text part to one which
operates on the whole Message. |
static <D> SimpleMessage<D> |
log(Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
log(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
logEnd(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
logStart(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
makeMessage(Message.Kind k,
Exception e,
String t,
Locatable<D> l)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
SimpleMessage<D> |
mapKind(Function<Message.Kind,Message.Kind> f)
Apply a function which operates on the
Kind part to construct
a new message. |
static <D,E> BiFunction<Function<Location<D>,Location<E>>,SimpleMessage<D>,SimpleMessage<E>> |
mapLocation()
A
BiFunction which delivers a clone of a SimpleMessage
and applies a mapping function on the Location part. |
<E> SimpleMessage<E> |
mapLocation(Function<Location<D>,Location<E>> f)
Apply a function which operates on the
Location part to construct
a new message. |
SimpleMessage<D> |
mapText(Function<String,String> f)
Apply a function which operates on the
text part to construct
a new message. |
static <D> Function<SimpleMessage<D>,String> |
messageToString(Function<? super Location<D>,? extends String> formatLoc)
Reified function for converting a message to a string,
using a given transformation function for the
Location part. |
static <D> Function<SimpleMessage<D>,String> |
messageToString(Function<? super Location<D>,? extends String> formatLoc,
Function<? super Message.Kind,String> formatKind) |
static <D> Thread |
monitor(Thread thread,
MessageReceiver<? super SimpleMessage<D>> receiver)
Installs a handler on the given thread that reports uncaught exceptions as
failure messages.
|
static <D> Thread |
monitor(Thread thread,
MessageReceiver<? super SimpleMessage<D>> receiver,
PrintStream ps)
Installs a handler on the given thread that reports uncaught exceptions as
failure messages.
|
static <X> SimpleMessage.Ping<X> |
ping()
Convenience factory Method:
Create an instance of
SimpleMessage.Ping ,
which is of kind Message.Kind.log . |
String |
render(Object... formatHints)
NOT YET OPERATIVE; simply calls
Message.toString() |
String |
toString()
Convert a message to a string, using the java default "toString(Object)"
for the
Location part. |
String |
toString(Function<? super Location<D>,? extends String> formatLoc)
Convert a message to a string, using a given transformation function
for the
Location part. |
String |
toString(Function<? super Location<D>,? extends String> formatLoc,
Function<? super Message.Kind,String> formatKind) |
static <D> SimpleMessage<D> |
warning(Locatable<D> loc,
String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
static <D> SimpleMessage<D> |
warning(String message)
Convenience factory Method:
Create a message of the indicated kind and with the given attributes.
|
explode, getException, getKind, getStackTrace, getTimeStamp, isCritical
@Opt protected final @Opt String text
public SimpleMessage(Message.Kind k, @Opt @Opt Exception e, @Opt @Opt String t)
k
- (never null)e
- (maybe null)t
- (maybe null)public SimpleMessage(Message.Kind k, @Opt @Opt Exception e, @Opt @Opt String t, @Opt @Opt Locatable<D> l)
k
- (never null)e
- (maybe null)t
- (maybe null)l
- (maybe null)public SimpleMessage(SimpleMessage<D> msg)
@Opt public final @Opt Location<D> getLocation()
@Opt public final @Opt String getText()
public static <D> Function<SimpleMessage<D>,String> messageToString(Function<? super Location<D>,? extends String> formatLoc)
Location
part.public static <D> Function<SimpleMessage<D>,String> messageToString(Function<? super Location<D>,? extends String> formatLoc, Function<? super Message.Kind,String> formatKind)
public String toString(Function<? super Location<D>,? extends String> formatLoc)
Location
part.public String toString(Function<? super Location<D>,? extends String> formatLoc, Function<? super Message.Kind,String> formatKind)
public String toString()
Location
part.public String render(Object... formatHints)
Message
Message.toString()
public SimpleMessage<D> mapKind(Function<Message.Kind,Message.Kind> f)
Kind
part to construct
a new message.public static <X> Function<SimpleMessage<X>,SimpleMessage<X>> liftMapKind(Function<Message.Kind,Message.Kind> f)
Kind
part to one which
operates on the whole Message.public <E> SimpleMessage<E> mapLocation(Function<Location<D>,Location<E>> f)
Location
part to construct
a new message. Consider when defining the function, that location maybe null.public static <D,E> Function<SimpleMessage<D>,SimpleMessage<E>> liftMapLocation(Function<Location<D>,Location<E>> f)
Location
(maybe null to maybe null) is given.
Partiality/totality is also lifted, unaltered.
(This function is used by e.g. xslt/base/TPathCache, d2d2/base/Main+others.)public static <D,E> BiFunction<Function<Location<D>,Location<E>>,SimpleMessage<D>,SimpleMessage<E>> mapLocation()
BiFunction
which delivers a clone of a SimpleMessage
and applies a mapping function on the Location
part.
Is used by FIXME ?????public SimpleMessage<D> mapText(Function<String,String> f)
text
part to construct
a new message.public static <X> Function<SimpleMessage<X>,SimpleMessage<X>> liftMapText(Function<String,String> f)
text
part to one which
operates on the whole Message.public static <D> SimpleMessage<D> makeMessage(Message.Kind k, Exception e, String t, Locatable<D> l)
public static <D> SimpleMessage<D> log(String message)
public static <D> SimpleMessage<D> log(Locatable<D> loc, String message)
public static <D> SimpleMessage<D> logStart(String message)
public static <D> SimpleMessage<D> logEnd(String message)
public static <D> SimpleMessage<D> hint(String message)
public static <D> SimpleMessage<D> hint(Locatable<D> loc, String message)
public static <D> SimpleMessage<D> warning(String message)
public static <D> SimpleMessage<D> warning(Locatable<D> loc, String message)
public static <D> SimpleMessage<D> error(String message)
public static <D> SimpleMessage<D> error(Locatable<D> loc, String message)
public static <D> SimpleMessage<D> error(Exception ex, String message)
public static <D> SimpleMessage<D> error(Exception ex, Locatable<D> loc, String message)
public static <D> SimpleMessage<D> failure(Exception th)
public static <D> SimpleMessage<D> failure(Exception exception, String message)
public static <D> SimpleMessage<D> failure(String message)
public static <D> SimpleMessage<D> failure(Locatable<D> loc, String message)
public static <D> SimpleMessage<D> failure(Locatable<D> loc, Exception exception)
public static <X> SimpleMessage.Ping<X> ping()
SimpleMessage.Ping
,
which is of kind Message.Kind.log
.public static <D> Thread monitor(Thread thread, MessageReceiver<? super SimpleMessage<D>> receiver)
monitor(thread, receiver, false)
.public static <D> Thread monitor(Thread thread, MessageReceiver<? super SimpleMessage<D>> receiver, PrintStream ps)
D
- the document identifier typethread
- the thread to monitorreceiver
- the receiver for the failure messageprintIt
- whether a stack trace shall be printed to the consoleThread.setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
,
failure(java.lang.Exception)
see also the complete user documentation .