class IPMatcher {

    public boolean match(String ipIn) throws IPMatcherException
    {
        log.debug("ipIn: "+ipIn);
        byte[] candidate;

        if (ipIn.indexOf(':') < 0)
        {
            candidate = new byte[4];
            ipToBytes(ipIn, candidate, true);
            candidate = ip4ToIp6(candidate);
        }
        else
            try
            {
                candidate = Inet6Address.getByName(ipIn).getAddress();
            }
            catch (UnknownHostException e)
            {
                throw new IPMatcherException("Malformed IPv6 address ",e);
            }

        for (int i = 0; i < netmask.length; i++)
        {
            if ((candidate[i] & netmask[i]) != (network[i] & netmask[i]))
            {
                if (log.isDebugEnabled()) {
                    log.debug("candidate[i]: "+candidate[i]);
                    log.debug("netmask[i]: "+netmask[i]);
                    log.debug("candidate[i] & netmask[i]: "+(candidate[i] & netmask[i]));
                    log.debug("network[i]: "+network[i]);
                    log.debug("network[i] & netmask[i]: "+(network[i] & netmask[i]));
                }
                return false;
            }
        }

        return true;
    }

    public  IPMatcher(String ipSpec);

}