/* Mozilla has to different id's; one up to version 4
/* Mozilla has two different id's; one up to version 4
    protected void detect()            throws org.apache.regexp.RESyntaxException {        if (agent == null || agent.length() == 0)            return;        String mav, miv, lang = null;        if (RE_START.match(agent)) {            browserName = RE_START.getParen(1);            mav = RE_START.getParen(3);            miv = RE_START.getParen(4);                        /* RE_MSIE hides itself behind Mozilla or different browserName,               good idea, congratulation Bill !            */            if (RE_MSIE.match(agent)) {                browserName = "MSIE";                browserType = BrowserType.IE;                mav = RE_MSIE.getParen(1);                miv = RE_MSIE.getParen(2);                release = RE_MSIE.getParen(3);                if (RE_MSIE_WIN_LANG_OS.match(agent)) {                    osType = OSType.WINDOWS;                    os = "Windows";                    osVersion = RE_MSIE_WIN_LANG_OS.getParen(2) +                            (RE_MSIE_WIN_LANG_OS.getParen(3) == null ?                            "" :                            " " + RE_MSIE_WIN_LANG_OS.getParen(3));                } else if (RE_MSIE_MAC_LANG_OS.match(agent)) {                    os = "MacOS";                    osType = OSType.MACOS;                }            }            /* Mozilla has to different id's; one up to version 4               and a second for version >= 5            */            else if (browserName.equals("Mozilla") || browserName == null) {                browserName = "Mozilla";                browserType = BrowserType.MOZILLA;                /* old mozilla */                if (RE_NS_LANG_OS.match(agent)) {                    lang = RE_NS_LANG_OS.getParen(1);                    os = RE_NS_LANG_OS.getParen(2);                    osVersion = RE_NS_LANG_OS.getParen(3);                    if (os.equals("X")) {                        if (RE_NS_X11_LANG_OS.match(agent)) {                            os = RE_NS_X11_LANG_OS.getParen(1);                            osVersion = RE_NS_X11_LANG_OS.getParen(2);                            osType = OSType.UNIX;                        }                    }                }                /* NS5, NS6 Galeon etc. */                else if (RE_GALEON_OS.match(agent)) {                    browserName = "Galeon";                    browserType = BrowserType.GECKO;                    os = RE_GALEON_OS.getParen(1);                    if (os.equals("X11")) {                        os = "Unix";                        osType = OSType.UNIX;                    }                    mav = RE_GALEON_OS.getParen(2);                    miv = RE_GALEON_OS.getParen(3);                } else if (RE_NS6_LANG_OS.match(agent)) {                    os = RE_NS6_LANG_OS.getParen(2);                    lang = RE_NS6_LANG_OS.getParen(5);                }                /* realy seldom but is there */                else if (RE_MSIE_WIN_LANG_OS.match(agent)) {                    os = "Windows";                    osType = OSType.WINDOWS;                    osVersion = RE_MSIE_WIN_LANG_OS.getParen(2) +                            (RE_MSIE_WIN_LANG_OS.getParen(3) == null ?                            "" :                            " " + RE_MSIE_WIN_LANG_OS.getParen(3));                }                /* Konqueror */                else if (RE_KONQUEROR_OS.match(agent)) {                    browserName = "Konqueror";                    browserType = BrowserType.KONQUEROR;                    StringTokenizer strtok = new StringTokenizer(RE_KONQUEROR_OS.getParen(1), ".");                    mav = strtok.nextToken();                    if (strtok.hasMoreTokens())                        miv = strtok.nextToken();                    if (strtok.hasMoreTokens())                        release = strtok.nextToken();                    os = RE_KONQUEROR_OS.getParen(2);                }                /* f*ck, what's that ??? */                else {                    browserName = "Mozilla";                    browserType = BrowserType.MOZILLA;                }                                /* reformat browser os */                if (os != null && os.startsWith("Win") &&                        (osVersion == null || osVersion.length() == 0)                ) {                    osVersion = os.substring(3, os.length());                    os = "Windows";                    osType = OSType.WINDOWS;                }                /* just any windows */                if (os != null && os.equals("Win")) {                    os = "Windows";                    osType = OSType.WINDOWS;                }            }            /* Opera identified as opera, that's easy! */            else if (browserName.equals("Opera")) {                browserType = BrowserType.OPERA;                if (RE_MSIE_WIN_LANG_OS.match(agent)) {                    os = "Windows";                    osType = OSType.WINDOWS;                    osVersion = RE_MSIE_WIN_LANG_OS.getParen(2) +                            (RE_MSIE_WIN_LANG_OS.getParen(3) == null ?                            "" :                            " " + RE_MSIE_WIN_LANG_OS.getParen(3));                } else if (RE_OPERA_LANG_OS.match(agent)) {                    os = RE_OPERA_LANG_OS.getParen(1);                    osVersion = RE_OPERA_LANG_OS.getParen(2);                    lang = RE_OPERA_LANG_OS.getParen(3);                }            }                        /* Opera identified as something else (Mozilla, IE ...) */            if (RE_OPERA.match(agent)) {                browserName = "Opera";                browserType = BrowserType.OPERA;                os = RE_OPERA.getParen(3);                osVersion = RE_OPERA.getParen(4);                mav = RE_OPERA.getParen(7);                miv = RE_OPERA.getParen(8);                lang = RE_OPERA.getParen(10);            }            /* detect gecko */            if (Gecko_Engine.match(agent)) {                browserType = BrowserType.GECKO;                if (Gecko_Engine.getParen(2) != null)                    browserName = Gecko_Engine.getParen(2);                if (Gecko_Engine.getParen(3) != null)                    mav = Gecko_Engine.getParen(3);                if (Gecko_Engine.getParen(4) != null)                    miv = Gecko_Engine.getParen(4);                if (Gecko_Engine.getParen(5) != null)                    release = Gecko_Engine.getParen(5);            }                        /* try to find language in uncommon places if not detected before */            if (lang == null) {                if (RE_LANG.match(agent)) {                    lang = RE_LANG.getParen(1);                }            }            try {                majorVersion = new Integer(mav).intValue();            } catch (NumberFormatException ex) {                majorVersion = 0;            }            try {                minorVersion = new Double("0." + miv).doubleValue();            } catch (NumberFormatException ex) {                minorVersion = 0f;            }            if (lang == null)                browserLocale = Locale.getDefault();            else {                /* Mozilla does that, maybe any other browser too ? */                lang = lang.replace('-', '_');                /* test for country extension */                StringTokenizer strtok = new StringTokenizer(lang, "_");                String l = strtok.nextToken();                if (strtok.hasMoreElements())                    browserLocale = new Locale(l, strtok.nextToken());                else                    browserLocale = new Locale(l, "");            }            if (osType == OSType.UNKNOWN && os != null) {                if (os.equals("Windows"))                    osType = OSType.WINDOWS;                else if (os.equals("MacOS"))                    osType = OSType.MACOS;                else if (                        os.equals("Linux") ||                        os.equals("AIX") ||                        os.equals("SunOS") ||                        os.equals("HP-UX") ||                        os.equals("Solaris") ||                        os.equals("BSD")                ) {                    osType = OSType.UNIX;                } else if (os.equals("os")) {                    osType = OSType.IBMOS;                }            }        }    }