/**
* @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidatorVars()
*/
protected java.util.Collection handleGetValidatorVars()
{
final Map vars = new LinkedHashMap();
final ClassifierFacade type = getType();
if (type != null)
{
final String format = getValidatorFormat();
if (format != null)
{
final boolean isRangeFormat = isRangeFormat(format);
if (isRangeFormat)
{
vars.put("min", Arrays.asList(new Object[]{"min", getRangeStart(format)}));
vars.put("max", Arrays.asList(new Object[]{"max", getRangeEnd(format)}));
}
else
{
final Collection formats = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
for (final Iterator formatIterator = formats.iterator(); formatIterator.hasNext();)
{
final String additionalFormat = String.valueOf(formatIterator.next());
if (isMinLengthFormat(additionalFormat)) vars.put("minlength",
Arrays.asList(new Object[]{"minlength", this.getMinLengthValue(additionalFormat)}));
else if (isMaxLengthFormat(additionalFormat)) vars.put("maxlength",
Arrays.asList(new Object[]{"maxlength", this.getMaxLengthValue(additionalFormat)}));
else if (isPatternFormat(additionalFormat)) vars
.put("mask", Arrays.asList(new Object[]{"mask", this.getPatternValue(additionalFormat)}));
}
}
}
if (isValidatorDate())
{
if (format != null && isStrictDateFormat(format))
{
vars.put("datePatternStrict",
Arrays.asList(new Object[]{"datePatternStrict", this.getDateFormat()}));
}
else
{
vars.put("datePattern", Arrays.asList(new Object[]{"datePattern", this.getDateFormat()}));
}
}
if (this.isValidatorTime())
{
vars.put("timePattern", Arrays.asList(new Object[]{"timePattern", this.getTimeFormat()}));
}
final String validWhen = getValidWhen();
if (validWhen != null)
{
vars.put("test", Arrays.asList(new Object[]{"test", validWhen}));
}
}
// custom (paramterized) validators are allowed here
// in this case we will reuse the validator arg values
Collection taggedValues = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDATORS);
for (final Iterator iterator = taggedValues.iterator(); iterator.hasNext();)
{
String validator = String.valueOf(iterator.next());
// guaranteed to be of the same length
List validatorVars = Bpm4StrutsUtils.parseValidatorVars(validator);
List validatorArgs = Bpm4StrutsUtils.parseValidatorArgs(validator);
for (int i = 0; i < validatorVars.size(); i++)
{
String validatorVar = (String)validatorVars.get(i);
String validatorArg = (String)validatorArgs.get(i);
vars.put(validatorVar, Arrays.asList(new Object[]{validatorVar, validatorArg}));
}
}
return vars.values();
}