{
int colonPos = definition.indexOf(':');
if (colonPos <= 0)
{
Message message = ERR_CHARSET_VALIDATOR_NO_COLON.get(definition);
throw new ConfigException(message);
}
else if (colonPos == (definition.length() - 1))
{
Message message = ERR_CHARSET_VALIDATOR_NO_CHARS.get(definition);
throw new ConfigException(message);
}
int minCount;
try
{
minCount = Integer.parseInt(definition.substring(0, colonPos));
}
catch (Exception e)
{
Message message = ERR_CHARSET_VALIDATOR_INVALID_COUNT.get(definition);
throw new ConfigException(message);
}
if (minCount <= 0)
{
Message message = ERR_CHARSET_VALIDATOR_INVALID_COUNT.get(definition);
throw new ConfigException(message);
}
String characterSet = definition.substring(colonPos+1);
for (int i=0; i < characterSet.length(); i++)
{
char c = characterSet.charAt(i);
if (usedCharacters.contains(c))
{
Message message = ERR_CHARSET_VALIDATOR_DUPLICATE_CHAR.get(
definition, String.valueOf(c));
throw new ConfigException(message);
}
usedCharacters.add(c);
}