if (jsc == null)
jsc = new JSourceCode();
jsc.add("DurationValidator typeValidator = new DurationValidator();");
if (hasMinimum()) {
Duration min = getMinExclusive();
if (min != null)
jsc.add("typeValidator.setMinExclusive(");
else {
min = getMinInclusive();
jsc.add("typeValidator.setMinInclusive(");
}
/* it is better for a good understanding to use
the parse method with 'min.toSring()' but in that case
we have to deal with the ParseException*/
jsc.append(
"new org.exolab.castor.types.Duration(" + min.toLong() + "L)");
jsc.append(");");
}
if (hasMaximum()) {
Duration max = getMaxExclusive();
if (max != null)
jsc.add("typeValidator.setMaxExclusive(");
else {
max = getMaxInclusive();
jsc.add("typeValidator.setMaxInclusive(");
}
/* it is better for a good understanding to use
the parse method with 'min.toSring()' but in that case
we have to deal with the ParseException*/
jsc.append(
"new org.exolab.castor.types.Duration(" + max.toLong() + "L)");
jsc.append(");");
}
//-- pattern facet
jsc.add(fieldValidatorInstanceName+".setValidator(typeValidator);");