public class MuLiMessageReceiver<D> extends SingleSender<SimpleMessage<D>> implements MessageReceiver<SimpleMessage<D>>
MessageReceiver, providing convenience methods
for generating and translating SimpleMessages.
CatalogByString and a (normally non-empty) list of language preferences,
as needed by MuLi.
MuLiMessageReceiver is mostly used as a generator for
messages: By calling the different generating methods error(...),
log(...), warning(...), etc., a SimpleMessage is
constructed (similar to the construction API in
SimpleMessage.Generator)
and sent to the one currently connected receiver, as defined
by SingleSender.
For this constructing, the message text itself and
all embedded components will (1) be translated separately and then (2) combined
by String formatting as described with
Catalog#translateAllAndFormatRobust(String,List,Object...) .
MessageCounter is fed in parallel
with the connected receiver. This can be retrieved by getCounter(),
and further inquired or reset, etc.
MessageReceiver. Then
they propagate all received messages after translating the text component
as a whole.
This is only sensible in the (rare) cases when the message texts are constants
as a whole, i.e. do not contain variable sub-texts.| Modifier and Type | Field and Description |
|---|---|
protected CatalogByString |
catalog |
protected MessageCounter |
counter |
protected List<String> |
prefs |
static String |
terminationText |
receiver| Constructor and Description |
|---|
MuLiMessageReceiver(MessageReceiver<SimpleMessage<D>> receiver,
CatalogByString cat,
List<String> prefs) |
MuLiMessageReceiver(MessageReceiver<SimpleMessage<D>> receiver,
CatalogByString cat,
String... prefs) |
| Modifier and Type | Method and Description |
|---|---|
void |
error(Exception cause,
Location<D> loc,
String txt,
Object... args)
(1) Translate the
text and all args, then (2) construct a
SimpleMessage and (3) send it to the current SingleSender.receiver. |
void |
error(Location<D> loc,
String txt,
Object... args) |
void |
error(String txt,
Object... args) |
void |
failure(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
failure(Location<D> loc,
String txt,
Object... args) |
void |
failure(String txt,
Object... args) |
CatalogByString |
getCatalog() |
MessageCounter |
getCounter() |
int |
getMarkedErros()
Returns the number of new critical errors
occured after the last call to
markCriticalErrors() |
List<String> |
getPrefs() |
void |
hint(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
hint(Location<D> loc,
String txt,
Object... args) |
void |
hint(String txt,
Object... args) |
void |
log(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
log(Location<D> loc,
String txt,
Object... args) |
void |
log(String txt,
Object... args) |
void |
logEnd(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
logEnd(Location<D> loc,
String txt,
Object... args) |
void |
logEnd(String txt,
Object... args) |
void |
logStart(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
logStart(Location<D> loc,
String txt,
Object... args) |
void |
logStart(String txt,
Object... args) |
int |
markCriticalErrors()
Stores the number of critical errors for later retrieval by
getMarkedErros(). |
static <X> MuLiMessageReceiver<X> |
noTranslate(MessageReceiver<SimpleMessage<X>> rec)
Wrap a MessageReceiver into a MuLiMessageReceiver with NOT TRANSLATION at all.
|
void |
receive(SimpleMessage<D> msg) |
protected void |
send(Message.Kind kind,
Exception cause,
Location<D> loc,
String txt,
List<Object> args) |
protected void |
send(Message.Kind kind,
Exception cause,
Location<D> loc,
String txt,
Object... args) |
void |
send(MuLiException exc) |
void |
setCatalog(CatalogByString catalog) |
void |
setPreferences(List<String> prefs) |
void |
setPreferences(String... prefs) |
void |
terminateApplicationOnErrors() |
void |
terminateApplicationOnErrors(int returnCode) |
void |
warning(Exception cause,
Location<D> loc,
String txt,
Object... args)
|
void |
warning(Location<D> loc,
String txt,
Object... args) |
void |
warning(String txt,
Object... args) |
getReceiver, send, setReceiverprotected CatalogByString catalog
protected MessageCounter counter
public static final String terminationText
public MuLiMessageReceiver(MessageReceiver<SimpleMessage<D>> receiver, CatalogByString cat, String... prefs)
cat - defines the translation process.
must be !=null.receiver - where to send the constructed (or propagated) messages.public MuLiMessageReceiver(MessageReceiver<SimpleMessage<D>> receiver, CatalogByString cat, List<String> prefs)
public static <X> MuLiMessageReceiver<X> noTranslate(MessageReceiver<SimpleMessage<X>> rec)
public void setCatalog(CatalogByString catalog)
public CatalogByString getCatalog()
public void setPreferences(String... prefs)
public void receive(SimpleMessage<D> msg)
receive in interface MessageReceiver<SimpleMessage<D>>public MessageCounter getCounter()
public int markCriticalErrors()
getMarkedErros().public int getMarkedErros()
markCriticalErrors()public void terminateApplicationOnErrors(int returnCode)
public void terminateApplicationOnErrors()
public void send(MuLiException exc)
protected void send(Message.Kind kind, Exception cause, Location<D> loc, String txt, Object... args)
protected void send(Message.Kind kind, Exception cause, Location<D> loc, String txt, List<Object> args)
public void error(Exception cause, Location<D> loc, String txt, Object... args)
text and all args, then (2) construct a
SimpleMessage and (3) send it to the current SingleSender.receiver.
prefs and the
contents of catalog, which must be != null.
The translation is done by delegation to
Catalog.translateAllAndFormatRobust(String,String[],,Object...)
type of the constructed method is
Message.Kind.error.
SingleSender.receiver is set,
as described in the
user documentation
public void warning(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). public void failure(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). public void hint(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). public void log(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). public void logStart(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). public void logEnd(Exception cause, Location<D> loc, String txt, Object... args)
#error(Exception,Location,String,Object...). see also the complete user documentation .