Package com.powsybl.commons.reporter
Class AbstractReporter
- java.lang.Object
-
- com.powsybl.commons.reporter.AbstractReporter
-
- All Implemented Interfaces:
Reporter
- Direct Known Subclasses:
Reporter.NoOpImpl
,ReporterModel
public abstract class AbstractReporter extends Object implements Reporter
An abstract class providing some default method implementations forReporter
implementations.- Author:
- Florian Dupuy
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.powsybl.commons.reporter.Reporter
Reporter.NoOpImpl
-
-
Field Summary
Fields Modifier and Type Field Description protected String
defaultName
protected String
taskKey
protected Map<String,TypedValue>
taskValues
-
Constructor Summary
Constructors Constructor Description AbstractReporter(String taskKey, String defaultName, Map<String,TypedValue> taskValues)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Reporter
createSubReporter(String taskKey, String defaultName)
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with no associated value.Reporter
createSubReporter(String taskKey, String defaultName, String key, Object value)
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with one associated value.Reporter
createSubReporter(String taskKey, String defaultName, String key, Object value, String type)
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with one associated typed value.protected static String
formatMessage(String message, Map<String,TypedValue> values)
Format given message by replacing value references by the corresponding values.protected static String
formatReportMessage(Report report, Map<String,TypedValue> taskValues)
Format default message of given report by replacing value references by the corresponding values.void
report(String reportKey, String defaultMessage)
Add a new report with no associated value.void
report(String reportKey, String defaultMessage, String valueKey, Object value)
Add a new report with one associated value.void
report(String reportKey, String defaultMessage, String valueKey, Object value, String type)
Add a new report with one associated typed value.void
report(String reportKey, String defaultMessage, Map<String,TypedValue> values)
Add a new report with its associated values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.powsybl.commons.reporter.Reporter
createSubReporter, report
-
-
-
-
Field Detail
-
taskKey
protected final String taskKey
-
defaultName
protected final String defaultName
-
taskValues
protected final Map<String,TypedValue> taskValues
-
-
Constructor Detail
-
AbstractReporter
public AbstractReporter(String taskKey, String defaultName, Map<String,TypedValue> taskValues)
-
-
Method Detail
-
createSubReporter
public Reporter createSubReporter(String taskKey, String defaultName)
Description copied from interface:Reporter
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with no associated value.- Specified by:
createSubReporter
in interfaceReporter
- Parameters:
taskKey
- the key identifying that taskdefaultName
- a name or message describing the corresponding task- Returns:
- the new sub-reporter
-
createSubReporter
public Reporter createSubReporter(String taskKey, String defaultName, String key, Object value)
Description copied from interface:Reporter
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with one associated value.- Specified by:
createSubReporter
in interfaceReporter
- Parameters:
taskKey
- the key identifying that taskdefaultName
- a name or message describing the corresponding task, which may contain references to the provided valuekey
- the key for the value which followsvalue
- the value which may be referred to within the defaultName or within the reports message of the created sub-reporter- Returns:
- the new sub-reporter
-
createSubReporter
public Reporter createSubReporter(String taskKey, String defaultName, String key, Object value, String type)
Description copied from interface:Reporter
Create a sub-reporter for a specific task, to separate from current reports the reports from that task, with one associated typed value.- Specified by:
createSubReporter
in interfaceReporter
- Parameters:
taskKey
- the key identifying that taskdefaultName
- a name or message describing the corresponding task, which may contain references to the provided typed valuekey
- the key for the typed value which followsvalue
- the value which may be referred to within the defaultName or within the reports message of the created sub-reportertype
- the string representing the type of the value provided- Returns:
- the new sub-reporter
-
report
public void report(String reportKey, String defaultMessage, Map<String,TypedValue> values)
Description copied from interface:Reporter
Add a new report with its associated values.- Specified by:
report
in interfaceReporter
- Parameters:
reportKey
- a key identifying the current reportdefaultMessage
- the default report message, which may contain references to the provided values or to the values of current reportervalues
- a map ofTypedValue
indexed by their key, which may be referred to within the defaultMessage provided
-
report
public void report(String reportKey, String defaultMessage)
Description copied from interface:Reporter
Add a new report with no associated value.
-
report
public void report(String reportKey, String defaultMessage, String valueKey, Object value)
Description copied from interface:Reporter
Add a new report with one associated value.- Specified by:
report
in interfaceReporter
- Parameters:
reportKey
- a key identifying the current reportdefaultMessage
- the default report message, which may contain references to the provided value or to the values of current reportervalueKey
- the key for the value which followsvalue
- the int, long, float, double, boolean or String value which may be referred to within the defaultMessage provided
-
report
public void report(String reportKey, String defaultMessage, String valueKey, Object value, String type)
Description copied from interface:Reporter
Add a new report with one associated typed value.- Specified by:
report
in interfaceReporter
- Parameters:
reportKey
- a key identifying the current reportdefaultMessage
- the default report message, which may contain references to the provided typed value or to the values of current reportervalueKey
- the key for the typed value which followsvalue
- the int, long, float, double, boolean or String value which may be referred to within the defaultMessage providedtype
- the string representing the type of the value provided
-
formatReportMessage
protected static String formatReportMessage(Report report, Map<String,TypedValue> taskValues)
Format default message of given report by replacing value references by the corresponding values. The values in the report default message have to be referred to with their corresponding key, using the${key}
syntax. The values are first searched in the report key-value map, then in or the given key-value map.StringSubstitutor
is used for the string replacements.- Parameters:
report
- the report whose default message needs to be formattedtaskValues
- the key-value map used if any value reference is not found among the report values- Returns:
- the resulting formatted string
-
formatMessage
protected static String formatMessage(String message, Map<String,TypedValue> values)
Format given message by replacing value references by the corresponding values. The values in the given message have to be referred to with their corresponding key, using the${key}
syntax.StringSubstitutor
is used for the string replacements.- Parameters:
message
- the message to be formattedvalues
- the key-value map used to look for the values- Returns:
- the resulting formatted string
-
-