*/
public void validate(AttributeMapping mapping, Object value) throws ValidationException
{
if (mapping instanceof RelationalPrimitiveMapping && value != null)
{
Column column = ((RelationalPrimitiveMapping)mapping).getColumn();
int nPrecision;
switch (column.getType().getOrdinal())
{
case Primitive.INTEGER_ORDINAL:
nPrecision = column.getPrecision();
switch (nPrecision)
{
case 1:
int nValue = ((Number)toBind(column, column.getValueType().convert(value))).intValue();
if (nValue < 0 || nValue > 255)
{
throw new ValidationException("err.validation.numberRange",
new Object[]
{
new StringId(mapping.getAttribute().getCaption()),
new StringId(mapping.getAttribute().getMetaclass().getCaption()),
Primitive.ZERO_INTEGER,
Primitive.createInteger(255)
});
}
break;
case 2:
nValue = ((Number)toBind(column, column.getValueType().convert(value))).intValue();
if (nValue < Short.MIN_VALUE || nValue > Short.MAX_VALUE)
{
throw new ValidationException("err.validation.numberRange",
new Object[]
{
new StringId(mapping.getAttribute().getCaption()),
new StringId(mapping.getAttribute().getMetaclass().getCaption()),
Primitive.createInteger(Short.MIN_VALUE),
Primitive.createInteger(Short.MAX_VALUE)
});
}
break;
}
break;
case Primitive.DECIMAL_ORDINAL:
nPrecision = column.getPrecision(getMaxDecimalPrecision());
int nScale = column.getScale(getMaxDecimalPrecision());
BigDecimal decMax = BigDecimal.TEN.pow(nPrecision - nScale);
if (((BigDecimal)toBind(column, column.getValueType().convert(value))).abs().setScale(nScale,
RoundingMode.HALF_UP).compareTo(decMax) >= 0)
{
if (nScale > 0)
{
decMax = decMax.subtract(BigDecimal.ONE.divide(BigDecimal.TEN.pow(nScale)));
}
throw new ValidationException("err.validation.numberRange",
new Object[]
{
new StringId(mapping.getAttribute().getCaption()),
new StringId(mapping.getAttribute().getMetaclass().getCaption()),
decMax.negate(),
decMax
});
}
break;
case Primitive.TIMESTAMP_ORDINAL:
long lTime = ((Timestamp)toBind(column, column.getValueType().convert(value))).getTime();
if (lTime < getMinTime() || lTime > getMaxTime())
{
throw new ValidationException("err.validation.dateRange",
new Object[]