public class DefaultJobParametersConverter extends Object implements JobParametersConverter
JobParameters
instances using a simple naming
convention for property keys. 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 String |
DATE_TYPE |
static String |
LONG_TYPE |
static String |
STRING_TYPE |
Constructor and Description |
---|
DefaultJobParametersConverter() |
Modifier and Type | Method and Description |
---|---|
JobParameters |
getJobParameters(Properties props)
Check for suffix on keys and use those to decide how to convert the
value.
|
Properties |
getProperties(JobParameters params)
Use the same suffixes to create properties (omitting the string suffix
because it is the default).
|
void |
setDateFormat(DateFormat dateFormat)
Public setter for injecting a date format.
|
void |
setNumberFormat(NumberFormat numberFormat)
Public setter for the
NumberFormat . |
public static final String DATE_TYPE
public static final String STRING_TYPE
public static final String LONG_TYPE
public JobParameters getJobParameters(Properties props)
getJobParameters
in interface JobParametersConverter
props
- the runtime parameters in the form of String literals.JobParameters
properties converted to the correct
types.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 Properties getProperties(JobParameters params)
getProperties
in interface JobParametersConverter
JobParametersConverter.getProperties(org.springframework.batch.core.JobParameters)
public void setDateFormat(DateFormat dateFormat)
dateFormat
- a DateFormat
, defaults to "yyyy/MM/dd"public void setNumberFormat(NumberFormat numberFormat)
NumberFormat
. Used to parse longs and
doubles, so must not contain decimal place (e.g. use "#" or "#,###").numberFormat
- the NumberFormat
to setCopyright © 2013 SpringSource. All rights reserved.