public class DefaultJobParametersConverter extends java.lang.Object implements JobParametersConverter
JobParameters instances using a simple naming
convention for property keys. Key names that are prefixed with a - are
considered non-identifying and will not contribute to the identity of a
JobInstance. Key names ending with "(<type>)" where
type is one of string, date, long are converted to the corresponding type.
The default type is string. E.g.
schedule.date(date)=2007/12/11 department.id(long)=2345The literal values are converted to the correct type using the default Spring strategies, augmented if necessary by the custom editors provided.
setDateFormat(DateFormat) and
setNumberFormat(NumberFormat)).| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DATE_TYPE |
static java.lang.String |
LONG_TYPE |
static java.lang.String |
STRING_TYPE |
| Constructor and Description |
|---|
DefaultJobParametersConverter() |
| Modifier and Type | Method and Description |
|---|---|
JobParameters |
getJobParameters(java.util.Properties props)
Check for suffix on keys and use those to decide how to convert the
value.
|
java.util.Properties |
getProperties(JobParameters params)
Use the same suffixes to create properties (omitting the string suffix
because it is the default).
|
void |
setDateFormat(java.text.DateFormat dateFormat)
Public setter for injecting a date format.
|
void |
setNumberFormat(java.text.NumberFormat numberFormat)
Public setter for the
NumberFormat. |
public static final java.lang.String DATE_TYPE
public static final java.lang.String STRING_TYPE
public static final java.lang.String LONG_TYPE
public JobParameters getJobParameters(@Nullable java.util.Properties props)
getJobParameters in interface JobParametersConverterprops - the runtime parameters in the form of String literals.JobParameters properties converted to the correct
types.java.lang.IllegalArgumentException - if a number or date is passed in that
cannot be parsed, or cast to the correct type.JobParametersConverter.getJobParameters(java.util.Properties)public java.util.Properties getProperties(@Nullable
JobParameters params)
NON_IDENTIFYING_FLAG. However, since parameters are
identifying by default, they will not be prefixed with the
IDENTIFYING_FLAG.getProperties in interface JobParametersConverterparams - the JobParameters instance to be converted.JobParametersConverter.getProperties(org.springframework.batch.core.JobParameters)public void setDateFormat(java.text.DateFormat dateFormat)
dateFormat - a DateFormat, defaults to "yyyy/MM/dd"public void setNumberFormat(java.text.NumberFormat numberFormat)
NumberFormat. Used to parse longs and
doubles, so must not contain decimal place (e.g. use "#" or "#,###").numberFormat - the NumberFormat to set