String tValue = value.trim();
int length = tValue.length();
if ( length < 9 )
{
throw new ConverterException(_getMessage(component, _SHORT_ERROR_TEXT));
}
if ( length > 11 )
{
throw new ConverterException(_getMessage(component, _LONG_ERROR_TEXT));
}
if (length == 9)
{
try
{
return Integer.valueOf(tValue);
}
catch(NumberFormatException nfe)
{
throw new ConverterException(_getMessage(component,
_INVALID_ERROR_TEXT));
}
}
if ( length == 11 &&
tValue.charAt(3) == '-' &&
tValue.charAt(6) == '-')
{
String v = tValue.substring(0,3) +
tValue.substring(4,6) +
tValue.substring(7);
try
{
return Integer.valueOf(v);
}
catch(NumberFormatException nfe)
{
throw new ConverterException(_getMessage(component,
_INVALID_ERROR_TEXT));
}
}
throw new ConverterException(_getMessage(component, _INVALID_ERROR_TEXT));
}