return getFields(clazz, "");
}
protected Map getFields(XClass clazz, String prefix) throws XDocletException
{
Map fields = new SequencedHashMap();
Collection curFields = clazz.getMethods(true);
// TODO: nested forms currently won't work unless
// there is a setter for it, but that is not needed
// as only the sub-forms must have setters. The top-level
// only requires a getter.
for (Iterator iterator = curFields.iterator(); iterator.hasNext(); ) {
XMethod method = (XMethod) iterator.next();
XTag tag = method.getDoc().getTag("struts.validator");
String override = null;
if (tag != null) {
override = tag.getAttributeValue("override");
}
if (tag != null) {
List params = method.getParameters();
String name = method.getPropertyName();
XParameter param = null;
if (MethodTagsHandler.isSetterMethod(method)) {
param = (XParameter) params.get(0);
}
else if (params.size() == 2) {
// Check for indexed setter setBlah(int index, <type> value)
if (!MethodTagsHandler.isSetter(method.getName()))
continue;
Iterator paramIter = params.iterator();
if (!((XParameter) paramIter.next()).getType().isA("int"))
continue;
if (name.indexOf("[]") >= 0) {
throw new XDocletException(Translator.getString(StrutsValidatorMessages.class,
StrutsValidatorMessages.ONLY_ONE_LEVEL_LIST_PROPS,
new String[]{clazz.getName() + '.' + name + "[]"}));
}
name = name + "[]";
param = (XParameter) paramIter.next();
}
else
continue;
String type = param.getType().getQualifiedName();
if (supportedTypes.contains(type)) {
fields.put(prefix + name, method);
}
else if ((override != null) && (override.equals("true"))) {
fields.put(prefix + name, method);
}
else {
boolean preDot = (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != '.');
fields.putAll(getFields(param.getType(), prefix + (preDot ? "." : "") + name + "."));
}
}
}
return fields;