// to generate.
if ((arguments == null) || (arguments.length == 0))
{
Message message =
ERR_MAKELDIF_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber);
throw new InitializationException(message);
}
int numArgs = arguments.length;
String randomTypeString = toLowerCase(arguments[0]);
if (randomTypeString.equals("alpha"))
{
characterSet = ALPHA_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
}
else if (randomTypeString.equals("numeric"))
{
if (numArgs == 2)
{
randomType = RANDOM_TYPE_CHARS_FIXED;
characterSet = NUMERIC_CHARS;
try
{
minLength = Integer.parseInt(arguments[1]);
if (minLength < 0)
{
Message message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(
minLength, 0, getName(), lineNumber);
throw new InitializationException(message);
}
else if (minLength == 0)
{
Message message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(
lineNumber);
warnings.add(message);
}
}
catch (NumberFormatException nfe)
{
Message message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(
arguments[1], getName(), lineNumber);
throw new InitializationException(message, nfe);
}
}
else if ((numArgs == 3) || (numArgs == 4))
{
randomType = RANDOM_TYPE_NUMERIC;
if (numArgs == 4)
{
try
{
decimalFormat = new DecimalFormat(arguments[3]);
}
catch (Exception e)
{
Message message = ERR_MAKELDIF_TAG_INVALID_FORMAT_STRING.get(
arguments[3], getName(), lineNumber);
throw new InitializationException(message, e);
}
}
else
{
decimalFormat = null;
}
try
{
minValue = Long.parseLong(arguments[1]);
}
catch (NumberFormatException nfe)
{
Message message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(
arguments[1], getName(), lineNumber);
throw new InitializationException(message, nfe);
}
try
{
maxValue = Long.parseLong(arguments[2]);
if (maxValue < minValue)
{
Message message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(
maxValue, minValue, getName(), lineNumber);
throw new InitializationException(message);
}
valueRange = maxValue - minValue + 1;
}
catch (NumberFormatException nfe)
{
Message message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(
arguments[2], getName(), lineNumber);
throw new InitializationException(message, nfe);
}
}
else
{
Message message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(
getName(), lineNumber, 2, 4, numArgs);
throw new InitializationException(message);
}
}
else if (randomTypeString.equals("alphanumeric"))
{
characterSet = ALPHANUMERIC_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
}
else if (randomTypeString.equals("chars"))
{
if ((numArgs < 3) || (numArgs > 4))
{
Message message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(
getName(), lineNumber, 3, 4, numArgs);
throw new InitializationException(message);
}
characterSet = arguments[1].toCharArray();
decodeLength(arguments, 2, lineNumber, warnings);
}
else if (randomTypeString.equals("hex"))
{
characterSet = HEX_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
}
else if (randomTypeString.equals("base64"))
{
characterSet = BASE64_CHARS;
decodeLength(arguments, 1, lineNumber, warnings);
}
else if (randomTypeString.equals("month"))
{
randomType = RANDOM_TYPE_MONTH;
if (numArgs == 1)
{
maxLength = 0;
}
else if (numArgs == 2)
{
try
{
maxLength = Integer.parseInt(arguments[1]);
if (maxLength <= 0)
{
Message message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(
maxLength, 1, getName(), lineNumber);
throw new InitializationException(message);
}
}
catch (NumberFormatException nfe)
{
Message message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(
arguments[1], getName(), lineNumber);
throw new InitializationException(message, nfe);
}
}
else
{
Message message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(
getName(), lineNumber, 1, 2, numArgs);
throw new InitializationException(message);
}
}
else if (randomTypeString.equals("telephone"))
{
randomType = RANDOM_TYPE_TELEPHONE;
}
else
{
Message message = ERR_MAKELDIF_TAG_UNKNOWN_RANDOM_TYPE.get(
lineNumber, randomTypeString);
throw new InitializationException(message);
}
}