{
Log log = LogUtil.getLog(ConfigTagsHandler.class, "getConfigParameter");
paramName = Introspector.decapitalize(paramName);
SubTask subtask = getDocletContext().getActiveSubTask();
if (log.isDebugEnabled()) {
log.debug("subtask=" + subtask.getClass());
log.debug("currentConfigParamIndex=" + currentConfigParamIndex);
log.debug("currentConfigParam=" + currentConfigParam);
log.debug("paramName=" + paramName);
}
String configName = paramName;
Object configValue = null;
int index = 0;
index = configName.indexOf('.');
if (index != -1) {
// so it's not in global namespace or activesubtask.param
int index2 = paramName.indexOf('.', index + 1);
// has one dot. subtaskname.param or activesubtask.element.param format
if (configValue == null && index2 == -1) {
// 1. is in subtaskname.param format
configName = paramName;
configValue = getDocletContext().getConfigParam(configName);
// 2. is in activesubtask.element.param format
if (configValue == null) {
String elemname = paramName.substring(0, index);
String paramname = paramName.substring(index + 1);
configName = subtask.getSubTaskName() + '.' + elemname;
configValue = getDocletContext().getConfigParam(configName);
// ok we have activesubtask.element value, use reflection to get
// the param inside the element
if (configValue != null) {
// we're in a forAllConfigParams loop for a ArrayList-based config parameter
if (currentConfigParamIndex != -1) {
log.debug("In a forAllConfigParams loop for an ArrayList-based config parameter.");
// param_value = element at currentConfigParamIndex index of the ArrayList
configValue = ((java.util.ArrayList) configValue).get(currentConfigParamIndex);
}
Method getterMethod = ConfigParamIntrospector.findGetterMethod(configValue, paramname);
if (getterMethod == null) {
configValue = null;
}
try {
configValue = getterMethod.invoke(configValue, null);
}
catch (Exception e) {
log.debug("not found", e);
}
}
}
}
else {
// has more than one dot. subtaskname.elem.param format
// lookup subtaskname.elem
int lastDotIndex = paramName.lastIndexOf('.');
String paramname = paramName.substring(lastDotIndex + 1);
configName = paramName.substring(0, lastDotIndex);
configValue = getDocletContext().getConfigParam(configName);
if (configValue != null) {
// we're in a forAllConfigParams loop for a ArrayList-based config parameter
if (currentConfigParamIndex != -1) {
log.debug("In a forAllConfigParams loop for an ArrayList-based config parameter.");
// param_value = element at currentConfigParamIndex index of the ArrayList
configValue = ((java.util.ArrayList) configValue).get(currentConfigParamIndex);
}
Method getterMethod = ConfigParamIntrospector.findGetterMethod(configValue, paramname);
if (getterMethod == null) {
configValue = null;
}
try {
configValue = getterMethod.invoke(configValue, null);
}
catch (Exception e) {
log.debug("not found", e);
}
}
}
}
else {
// is either in global namespace or activesubtask.param
// 1. search active subtask
configName = subtask.getSubTaskName() + '.' + paramName;
configValue = getDocletContext().getConfigParam(configName);
// 2. search DocletTask global namespace
if (configValue == null) {
configName = paramName;