in jbatch/src/main/java/org/apache/batchee/container/modelresolver/impl/AbstractPropertyResolver.java [290:363]
private NextProperty findNextProperty(final String str, final int startIndex) {
if (str == null) {
return null;
}
final int startPropIndex = str.indexOf("#{", startIndex);
if (startPropIndex == -1) {
return null;
}
//FIXME We may want to throw a more helpful exception here to say there was probably a typo.
PropertyType type = null;
if (str.startsWith("#{jobParameters['", startPropIndex)) {
type = PropertyType.JOB_PARAMETERS;
} else if (str.startsWith("#{systemProperties['", startPropIndex)) {
type = PropertyType.SYSTEM_PROPERTIES;
} else if (str.startsWith("#{jobProperties['", startPropIndex)) {
type = PropertyType.JOB_PROPERTIES;
} else if (isPartitionedStep && str.startsWith("#{partitionPlan['", startPropIndex)) {
type = PropertyType.PARTITION_PROPERTIES;
}
if (type == null) {
return null;
}
final int endPropIndex = str.indexOf("']}");
// This check allows something like this "Some filename is ${jobParameters['']}"
// Maybe we should require "${f}" ???
String propName = null;
String defaultPropExpression = null;
if (endPropIndex > startPropIndex) {
//look for the ?:<default-value-expression>; syntax after the property to see if it has a default value
if (str.startsWith("?:", endPropIndex + "']}".length())) {
//find the end of the defaulting string
int tempEndPropIndex = str.indexOf(";", endPropIndex + "']}?:".length());
if (tempEndPropIndex == -1) {
throw new IllegalArgumentException("The default property expression is not properly terminated with ';'");
}
//this string does not include the ?: and ; It only contains the content in between
defaultPropExpression = str.substring(endPropIndex + "]}?:".length() + 1, tempEndPropIndex);
}
if (type.equals(PropertyType.JOB_PARAMETERS)) {
propName = str.substring(startPropIndex + "#{jobParameters['".length(), endPropIndex);
}
if (type.equals(PropertyType.JOB_PROPERTIES)) {
propName = str.substring(startPropIndex + "#{jobProperties['".length(), endPropIndex);
}
if (type.equals(PropertyType.SYSTEM_PROPERTIES)) {
propName = str.substring(startPropIndex + "#{systemProperties['".length(), endPropIndex);
}
if (type.equals(PropertyType.PARTITION_PROPERTIES)) {
propName = str.substring(startPropIndex + "#{partitionPlan['".length(), endPropIndex);
}
return new NextProperty(propName, type, startPropIndex, endPropIndex, defaultPropExpression);
}
// if no variables like #{jobProperties['prop1']} are in string, return null
return null;
}