class RequireDebianCompatibleVersionRule implements EnforcerRule {

    public void ensureValidDebianVersion(String version) throws EnforcerRuleException
    {
        if (version.endsWith("SNAPSHOT"))
        {
            // Skip check on SNAPSHOT versions.
            return;
        }

        if (version.contains("-"))
        {
            throw new EnforcerRuleException("The version \"" + version + "\" does not conform to the Debian (linux packaging) version requirements.  "
                    + "It can't have the '-' character as it has a special meaning reserved for the DEB process (package build #).");
        }

        if (version.contains("_"))
        {
            throw new EnforcerRuleException("The version \"" + version + "\" does not conform to the Debian (linux packaging) version requirements.  "
                    + "It can't have the '_' character as it has a special meaning reserved for the DEB process "
                    + "(indicates split between package name, version, and architecture on filename).");
        }

        // Architecture IDs 
        String reserved[] =
        { "all", "i386", "i486", "i586", "i686", "pentium", "athlon", "ia64", "x86_64", "amd64", "ia32", "alpha", "sparc", "m68k", "ppc", "hppa", "arm" };

        String lversion = version.toLowerCase();
        for (String id : reserved)
        {
            if (lversion.contains(id))
            {
                throw new EnforcerRuleException("The version \"" + version + "\" does not conform to the Debian (linux packaging) version requirements.  "
                        + "It can't use the DEB reserved word \"" + id + "\".");
            }
        }
    }

}