public class LocalisedCheckReport extends CheckReport
| Modifier and Type | Class and Description |
|---|---|
static class |
LocalisedCheckReport.LocalisedReportEntry
A report entry extension providing localised messages.
|
CheckReport.ReportEntry, CheckReport.ResultType| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.util.Locale> |
locales
The locales this check report should provide.
|
protected LocalisationFactory |
locFac
The localisation factory which to use for localising attributes from model elements.
|
locale, nextEntryNumber, reportEntries| Constructor and Description |
|---|
LocalisedCheckReport(java.net.URI base,
LocalisationFactory locFac,
java.util.Locale... locales)
Creates a localised check report for the designated base URI providing the designated locales
(and their fallbacks) using the designated localisation factory.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addLocalisedReportEntry(CheckReport report,
java.lang.String checkId,
CheckReport.ResultType reportEntryType,
java.net.URI[] affectedElements,
java.lang.String msgKey,
java.lang.String bundleName,
java.lang.Class<?> localisingClass,
LocalisedString... args)
Adds a report entry with a localised message/with localised messages to the designated check
report.
|
void |
addReportEntry(java.lang.String checkID,
CheckReport.ResultType reportEntryType,
java.lang.String defaultMessage,
java.util.Map<java.util.Locale,java.lang.String> localisedMessage,
java.net.URI... affElems)
Adds a new localisable entry to the report.
|
void |
addReportEntry(java.lang.String checkID,
CheckReport.ResultType reportEntryType,
java.lang.String defaultMessage,
java.net.URI... affElems)
Adds a new entry to the report.
|
static CheckReport |
createLocalisedCheckReport(java.net.URI base,
LocalisationFactory locFac,
java.util.Locale... locales)
Convenience method for creating a check report respecting localisation.
|
java.util.List<? extends LocalisedCheckReport.LocalisedReportEntry> |
getEntriesForCheckID(java.lang.String checkID)
Returns all check report entries which do have the given checkID
|
LocalisedCheckReport.LocalisedReportEntry |
getLastAddedReportEntry()
Returns the last added report entry
|
LocalisationFactory |
getLocalisationFactory()
Gets the localisation factory which to use for localising attributes from model elements or
null if model elements should not be localised. |
static java.lang.String |
getLocalisedMessage(java.lang.String msgKey,
java.lang.String bundleName,
java.util.Locale locale,
java.lang.Class<?> localisingClass,
CheckReport report,
LocalisedString... args)
Gets the localised message for the designated message key from the designated bundle for the
designated locale.
|
java.util.List<java.util.Locale> |
getPreferredLocales()
Gets the locales this check report should provide (or at least a fallback for each of the
locales).
|
java.util.List<? extends LocalisedCheckReport.LocalisedReportEntry> |
getReportEntries()
Returns all report entries that keep the output of the different checks and
are assigned to the check report.
|
java.lang.String |
getReportSummary(java.util.Locale loc)
Gets a report summary of all check report entries using the designated locale for all messages.
|
java.lang.String |
getSimpleReportSummary(java.util.Locale loc)
Gets a report summary of all warning and failure check report entries using the designated
locale for all messages.
|
void |
printReportSummary(java.util.Locale loc)
Prints the report summary to STDOUT using the designated locale.
|
void |
setLocalisationFactory(LocalisationFactory locFac)
Sets the localisation factory if it is not set yet.
|
addReportEntry, getBase, getCheckResult, getPreferredLocale, getReportSummary, getSimpleReportSummary, printReportSummaryprotected final java.util.List<java.util.Locale> locales
protected transient LocalisationFactory locFac
null, model elements will not be localised.public LocalisedCheckReport(java.net.URI base,
LocalisationFactory locFac,
java.util.Locale... locales)
null, use a CheckReport instead. This also
applies when using only Locale.ROOT.base - The process element identifier URI of the template or instance this check report is
assigned to.locFac - The localisation factory which to use for localising attributes from model
elements. If this is null, model elements will not be localised.locales - The locales this check report should provide. This must not be empty; if you do
not need locales, use a CheckReport instead.public java.util.List<java.util.Locale> getPreferredLocales()
public LocalisationFactory getLocalisationFactory()
null if model elements should not be localised.null if model elements should not be localised.public void addReportEntry(java.lang.String checkID,
CheckReport.ResultType reportEntryType,
java.lang.String defaultMessage,
java.net.URI... affElems)
CheckReportreportEntryType.addReportEntry in class CheckReportcheckID - The identifier of the check that generates this report
entry.reportEntryType - The severity of this report item.defaultMessage - The message to report.affElems - The process element identifier URIs of the process
elements affected by this report entry.public void addReportEntry(java.lang.String checkID,
CheckReport.ResultType reportEntryType,
java.lang.String defaultMessage,
java.util.Map<java.util.Locale,java.lang.String> localisedMessage,
java.net.URI... affElems)
reportEntryType.checkID - The identifier of the check that generates this report entry.reportEntryType - The severity of this report item.defaultMessage - The default message used if no corresponding localisation is found.localisedMessage - The localised message for the corresponding locale. This should contain
all preferred locales (or at least the
corresponding fallbacks) of the check report.affElems - The process element identifier URIs of the process elements affected by this
report entry.public java.util.List<? extends LocalisedCheckReport.LocalisedReportEntry> getReportEntries()
CheckReportgetReportEntries in class CheckReportpublic java.lang.String getReportSummary(java.util.Locale loc)
loc - The locale which to use for the messages in the report summary.CheckReport.getReportSummary()public java.lang.String getSimpleReportSummary(java.util.Locale loc)
loc - The locale which to use for the messages in the simple report summary.CheckReport.getSimpleReportSummary()public void printReportSummary(java.util.Locale loc)
loc - The locale which to use for the printed messages.public java.util.List<? extends LocalisedCheckReport.LocalisedReportEntry> getEntriesForCheckID(java.lang.String checkID)
CheckReportgetEntriesForCheckID in class CheckReportpublic LocalisedCheckReport.LocalisedReportEntry getLastAddedReportEntry()
CheckReportgetLastAddedReportEntry in class CheckReportpublic void setLocalisationFactory(LocalisationFactory locFac)
locFac - The localisation factory to be set for this check report.public static CheckReport createLocalisedCheckReport(java.net.URI base, LocalisationFactory locFac, java.util.Locale... locales)
LocalisedCheckReport unless for one locale without an localisation factory or for
the root locale only. In this case it will be a simple CheckReport.base - The process element identifier URI of the template or instance this check report is
assigned to.locFac - The localisation factory which to use for localising attributes from model
elements. If this is null, model elements will not be localised.locales - The locale(s) the created check report should provide. This may be
null.LocalisedCheckReport for several locales, a simple
CheckReport for one or no specific locale.public static void addLocalisedReportEntry(CheckReport report, java.lang.String checkId, CheckReport.ResultType reportEntryType, java.net.URI[] affectedElements, java.lang.String msgKey, java.lang.String bundleName, java.lang.Class<?> localisingClass, LocalisedString... args)
CheckReport having only one preferred
localisation and a LocalisedCheckReport having several preferred localisations.report - The check report to which to add a localised report entry.checkId - The ID of the check that generates this report entry.reportEntryType - The severity of this report item.affectedElements - The (URIs of the) affected elements that caused the report entry.msgKey - The message key with which to retrieve the localisation from the resource
bundles.bundleName - The name of the resource bundle.localisingClass - The class that is performing the localisation. This is used for loading
the resource bundle.args - Optional arguments passed to the corresponding localised message using
String.format(Locale, String, Object...). Make sure that only model elements
or variables from the calling context need late localisation. Do not try to localise
simple strings that belong to the message body. For instance,
"input parameter" or "output parameter" need to be localised in
the resource bundle not by the means of LocalisedString. Use different
msgKeys for such cases.public static java.lang.String getLocalisedMessage(java.lang.String msgKey,
java.lang.String bundleName,
java.util.Locale locale,
java.lang.Class<?> localisingClass,
CheckReport report,
LocalisedString... args)
msgKey - The message key with which to retrieve the localisation from the resource bundle.bundleName - The name of the resource bundle.locale - The locale for which to retrieve the localisation for the designated message key.localisingClass - The class that is performing the localisation. This is used for loading
the resource bundle.report - The check report providing the localisation factory. If the check report is
null or does not provide one, no special localisation will be applied to
the strings.args - Optional arguments localised and afterwards passed to the corresponding localised
message using String.format(Locale, String, Object...).LocalisationTools.getLocalisedMessage(String, String, Locale, Class, LocalisationFactory,
LocalisedString...)