public class ExpandedJobParametersConverter
extends org.springframework.batch.core.converter.DefaultJobParametersConverter
JobParametersConverter
. Allows to convert a wide variety of object types
to JobParameters
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABSOLUTE_FILE_PATH |
static java.lang.String |
IS_RESTART_JOB_PARAMETER_KEY |
protected org.slf4j.Logger |
logger |
static java.lang.String |
UNIQUE_JOB_PARAMETER_KEY |
Constructor and Description |
---|
ExpandedJobParametersConverter()
Default Constructor, initializing
DefaultJobParametersConverter.setDateFormat(DateFormat)
with TimeUtils.getDefaultDateFormat() . |
Modifier and Type | Method and Description |
---|---|
org.springframework.batch.core.JobParameters |
getJobParameters(java.util.Properties properties)
If
makeParametersUnique is true the JobParameter with key
UNIQUE_JOB_PARAMETER_KEY will be added with a random number value. |
java.lang.String |
getJobParametersAsString(org.springframework.batch.core.JobParameters jobParameters)
This method will convert
JobParameters to a JSON String. |
java.lang.String |
getJobParametersAsString(org.springframework.batch.core.JobParameters jobParameters,
boolean isRestart)
This method will convert
JobParameters to a JSON String. |
org.springframework.batch.core.JobParameters |
getJobParametersForFile(java.io.File file)
Return
JobParameters for the passed-in File . |
org.springframework.batch.core.JobParameters |
getJobParametersForJsonString(java.lang.String jobParametersAsJsonMap)
Converts a
String -based JSON map to JobParameters . |
org.springframework.batch.core.JobParameters |
getJobParametersForMap(java.util.Map<?,?> map)
Will convert the provided
Map into JobParameters . |
org.springframework.batch.core.JobParameters |
removeRestartParameterIfExists(org.springframework.batch.core.JobParameters jobParameters)
If
JobParameters contains a parameters named "XD_isRestart" removed it. |
void |
setDateFormat(java.text.DateFormat dateFormat)
Will set the
DateFormat on the underlying DefaultJobParametersConverter . |
void |
setDateFormatAsString(java.lang.String dateFormatAsString)
Allows for setting the
DateFormat using a String . |
void |
setMakeParametersUnique(boolean makeParametersUnique)
If not set, this property defaults to
true . |
void |
setNumberFormat(java.text.NumberFormat numberFormat)
Setter for the
NumberFormat which is set on the underlying DefaultJobParametersConverter . |
void |
setNumberFormatAsString(java.lang.String numberFormatAsString)
Allows for setting the
NumberFormat using a String . |
protected final org.slf4j.Logger logger
public static final java.lang.String ABSOLUTE_FILE_PATH
public static final java.lang.String UNIQUE_JOB_PARAMETER_KEY
public static final java.lang.String IS_RESTART_JOB_PARAMETER_KEY
public ExpandedJobParametersConverter()
DefaultJobParametersConverter.setDateFormat(DateFormat)
with TimeUtils.getDefaultDateFormat()
.public void setDateFormat(java.text.DateFormat dateFormat)
DateFormat
on the underlying DefaultJobParametersConverter
. If not set explicitly,
the DateFormat
will default to TimeUtils.getDefaultDateFormat()
.setDateFormat
in class org.springframework.batch.core.converter.DefaultJobParametersConverter
dateFormat
- Must not be nullpublic void setDateFormatAsString(java.lang.String dateFormatAsString)
DateFormat
using a String
. If not
set, the default DateFormat
used will be TimeUtils.getDefaultDateFormat()
.dateFormatAsString
- Will be ignored if null or empty.public void setMakeParametersUnique(boolean makeParametersUnique)
true
.makeParametersUnique
- If not set defaults to true
public void setNumberFormat(java.text.NumberFormat numberFormat)
NumberFormat
which is set on the underlying DefaultJobParametersConverter
. If not
set explicitly, defaults to NumberFormat.getInstance(Locale.US);
setNumberFormat
in class org.springframework.batch.core.converter.DefaultJobParametersConverter
numberFormat
- Must not be null.public void setNumberFormatAsString(java.lang.String numberFormatAsString)
NumberFormat
using a String
. The passed-in String will be converted to a
DecimalFormat
.numberFormatAsString
- Will be ignored if null or empty.public org.springframework.batch.core.JobParameters getJobParametersForFile(java.io.File file)
JobParameters
for the passed-in File
. Will set the JobParameter
with key
ABSOLUTE_FILE_PATH
to the File
's absolutePath. Method will ultimately call
getJobParameters(Properties)
.file
- Must not be null.public org.springframework.batch.core.JobParameters getJobParametersForJsonString(java.lang.String jobParametersAsJsonMap)
String
-based JSON map to JobParameters
. The String is converted using Jackson's
ObjectMapper
.
The method will ultimately call getJobParametersForMap(Map)
.jobParametersAsJsonMap
- Can be null or empty.public org.springframework.batch.core.JobParameters getJobParametersForMap(java.util.Map<?,?> map)
Map
into JobParameters
. The method will ultimately call
getJobParameters(Properties)
.map
- Can be null or an empty Map
.public org.springframework.batch.core.JobParameters getJobParameters(java.util.Properties properties)
makeParametersUnique
is true
the JobParameter
with key
UNIQUE_JOB_PARAMETER_KEY
will be added with a random number value.
The method will ultimately call DefaultJobParametersConverter.getJobParameters(Properties)
.getJobParameters
in interface org.springframework.batch.core.converter.JobParametersConverter
getJobParameters
in class org.springframework.batch.core.converter.DefaultJobParametersConverter
properties
- Can be null.public java.lang.String getJobParametersAsString(org.springframework.batch.core.JobParameters jobParameters)
JobParameters
to a JSON String. The parameters in the resulting JSON String are
sorted by the name of the parameters.
This method will delegate to getJobParametersAsString(JobParameters, boolean)
jobParameters
- Must not be nullJobParameters
public java.lang.String getJobParametersAsString(org.springframework.batch.core.JobParameters jobParameters, boolean isRestart)
JobParameters
to a JSON String. The parameters in the resulting JSON String are
sorted by the name of the parameters.jobParameters
- Must not be nullisRestart
- When true
, add a restart flagJobParameters
public org.springframework.batch.core.JobParameters removeRestartParameterIfExists(org.springframework.batch.core.JobParameters jobParameters)
JobParameters
contains a parameters named "XD_isRestart" removed it.jobParameters
- Must not be nullJobParameters