in src/main/java/org/apache/bsf/util/StringUtils.java [337:378]
public static boolean isValidPackageName(final String packageName)
{
if (packageName == null) {
return false;
} else if (packageName.length() == 0) {
// Empty is ok.
return true;
}
final StringTokenizer strTok = new StringTokenizer(packageName, ".", true);
// Should have an odd number of tokens (including '.' delimiters).
if (strTok.countTokens() % 2 != 1) {
return false;
}
// Must start with a valid identifier name.
if (!isValidIdentifierName(strTok.nextToken())) {
return false;
}
// ... followed by 0 or more of ".ValidIdentifier".
while (strTok.hasMoreTokens())
{
// Must be a '.'.
if (!strTok.nextToken().equals(".")) {
return false;
}
// Must be a valid identifier name.
if (strTok.hasMoreTokens())
{
if (!isValidIdentifierName(strTok.nextToken())) {
return false;
}
} else {
return false;
}
}
return true;
}