// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   Platform.java

package com.symantec.itools.lang;

import com.symantec.itools.util.Properties;
import java.io.PrintStream;

// Referenced classes of package com.symantec.itools.lang:
//            IllegalInstantiationError

public class Platform
{

    protected Platform()
    {
        throw new IllegalInstantiationError(com.symantec.itools.lang.Platform.class);
    }

    public static boolean isJavaVendor(String s)
    {
        return s.equals(javaVendor);
    }

    public static boolean isJavaVersion(String s)
    {
        return s.equals(javaVersion);
    }

    public static boolean isOSType(String s)
    {
        return s.equals(osType);
    }

    public static boolean isOSName(String s)
    {
        return s.equals(osName);
    }

    public static boolean isArchitecture(String s)
    {
        return s.equals(architecture);
    }

    public static boolean isJavaVendor(String s, String s1)
    {
        return s.equals(lookupJavaVendor(vmProperties, s1));
    }

    public static boolean isJavaVersion(String s, String s1, String s2)
    {
        return s.equals(lookupJavaVersion(vmProperties, s1, s2));
    }

    public static boolean isOSType(String s, String s1)
    {
        return s.equals(lookupOSType(osProperties, s1));
    }

    public static boolean isOSName(String s, String s1, String s2)
    {
        return s.equals(lookupOSName(osProperties, s1, s2));
    }

    public static boolean isArchitecture(String s, String s1, String s2)
    {
        return s.equals(lookupArchitecture(machineProperties, s1, s2));
    }

    public static String getJavaVendor(String s)
    {
        return lookupJavaVendor(vmProperties, s);
    }

    public static String getJavaVersion(String s, String s1)
    {
        return lookupJavaVersion(vmProperties, s, s1);
    }

    public static String getOSType(String s)
    {
        return lookupOSType(osProperties, s);
    }

    public static String getOSName(String s, String s1)
    {
        return lookupOSName(osProperties, s, s1);
    }

    public static String getArchitecture(String s, String s1)
    {
        return lookupArchitecture(machineProperties, s, s1);
    }

    private static String lookupJavaVendor(Properties properties1, String s)
    {
        if(properties1 == null || s == null)
            return null;
        Properties properties2 = properties1.getProperties("vendors");
        if(properties2 == null)
            throw new RuntimeException("Need a better error - vendorInfo is null");
        String as[] = properties2.getStringList("vendors");
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties2.getStringList(as[i]);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static String lookupJavaVersion(Properties properties1, String s, String s1)
    {
        if(properties1 == null || s == null || s1 == null)
            return null;
        Properties properties2 = properties1.getProperties("versions");
        if(properties2 == null)
            throw new RuntimeException("Need a better error - versionInfo is null");
        String as[] = properties2.getStringList("versions");
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties2.getStringList(as[i] + '.' + s1);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static String lookupOSName(Properties properties1, String s, String s1)
    {
        if(properties1 == null || s == null || s1 == null)
            return null;
        Properties properties2 = properties1.getProperties("names");
        if(properties2 == null)
            throw new RuntimeException("Need a better error - nameInfo is null");
        String as[] = properties2.getStringList("names");
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties2.getStringList(as[i] + '.' + s1);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static String lookupOSVersion(Properties properties1, String s, String s1, String s2)
    {
        if(properties1 == null || s1 == null || s1 == null || s2 == null)
            return null;
        Properties properties2 = properties1.getProperties("versions");
        if(properties2 == null)
            throw new RuntimeException("Need a better error - versionInfo is null");
        String as[] = properties2.getStringList(s2);
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties2.getStringList(s2 + '.' + as[i] + '.' + s1);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static String lookupOSType(Properties properties1, String s)
    {
        if(properties1 == null || s == null)
            return null;
        Properties properties2 = properties1.getProperties("types");
        if(properties2 == null)
            throw new RuntimeException("Need a better error - typesInfo is null");
        String as[] = properties2.getStringList("types");
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties2.getStringList(as[i]);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static String lookupArchitecture(Properties properties1, String s, String s1)
    {
        if(properties1 == null || s == null || s1 == null)
            return null;
        String as[] = properties1.getStringList("machines");
        for(int i = 0; i < as.length; i++)
        {
            String as1[] = properties1.getStringList(as[i] + '.' + s1);
            for(int j = 0; j < as1.length; j++)
                if(s.equals(as1[j]))
                    return as[i];

        }

        return null;
    }

    private static void reportErrorFor(String s, String s1, boolean flag)
    {
        if(s1 == null)
        {
            System.out.print("Platform doesn't know about " + s);
            if(flag)
                System.out.print(": " + System.getProperty(s));
            System.out.println();
        }
    }

    private static void fixupOSName()
    {
        if((osName == null) | (osVersion == null))
            return;
        if(osName.equals("Windows95") && osVersion.equals("4.10"))
            osName = "Windows98";
    }

    public static void main(String args[])
    {
    }

    protected static boolean reportErrors;
    protected static String javaVendor;
    protected static String javaVersion;
    protected static String osName;
    protected static String osVersion;
    protected static String osType;
    protected static String architecture;
    protected static Properties properties;
    public static final String VENDOR_APPLE = "Apple";
    public static final String VENDOR_IBM = "IBM";
    public static final String VENDOR_MICROSOFT = "Microsoft";
    public static final String VENDOR_NETSCAPE = "Netscape";
    public static final String VENDOR_SGI = "SGI";
    public static final String VENDOR_SUN = "Sun";
    public static final String VENDOR_SYMANTEC = "Symantec";
    public static final String VENDOR_DEC = "DEC";
    public static final String VENDOR_HP = "HP";
    public static final String VENDOR_LINUX_PORT = "LinuxPort";
    public static final String JDK_1_1 = "1-1";
    public static final String JDK_1_2 = "1-2";
    public static final String OS_WINDOWS_NT = "WindowsNT";
    public static final String OS_WINDOWS_95 = "Windows95";
    public static final String OS_WINDOWS_98 = "Windows98";
    public static final String OS_MACINTOSH = "Macintosh";
    public static final String OS_SOLARIS = "Solaris";
    public static final String OS_IRIX = "Irix";
    public static final String OS_DIGITAL_UNIX = "DigitalUnix";
    public static final String OS_AIX = "AIX";
    public static final String OS_HPUX = "HPUX";
    public static final String OS_LINUX = "Linux";
    public static final String OS_TYPE_MAC_OS = "MacOS";
    public static final String OS_TYPE_WINDOWS = "Windows";
    public static final String OS_TYPE_UNIX = "Unix";
    public static final String ARCHITECTURE_MIPS = "MIPS";
    public static final String ARCHITECTURE_X86 = "x86";
    public static final String ARCHITECTURE_ALPHA = "ALPHA";
    public static final String ARCHITECTURE_SPARC = "SPARC";
    public static final String ARCHITECTURE_PA_RISC = "PA-RISC";
    protected static Properties vmProperties;
    protected static Properties osProperties;
    protected static Properties machineProperties;

    static 
    {
        try
        {
            properties = new Properties("/com/symantec/itools/lang/Platform.properties");
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
        reportErrors = true;
        try
        {
            vmProperties = properties.getProperties("vm");
            osProperties = properties.getProperties("os");
            machineProperties = properties.getProperties("machine");
            javaVendor = lookupJavaVendor(vmProperties, System.getProperty("java.vendor").trim());
            if(javaVendor != null)
            {
                javaVersion = lookupJavaVersion(vmProperties, System.getProperty("java.version").trim(), javaVendor);
                osName = lookupOSName(osProperties, System.getProperty("os.name").trim(), javaVendor);
                if(osName != null)
                {
                    osVersion = lookupOSVersion(osProperties, System.getProperty("os.version").trim(), javaVendor, osName);
                    osType = lookupOSType(osProperties, osName);
                }
                architecture = lookupArchitecture(machineProperties, System.getProperty("os.arch").trim(), javaVendor);
            }
        }
        catch(Throwable throwable1)
        {
            throwable1.printStackTrace();
        }
        fixupOSName();
        if(reportErrors)
        {
            reportErrorFor("java.vendor", javaVendor, true);
            reportErrorFor("java.version", javaVersion, true);
            reportErrorFor("os.name", osName, true);
            reportErrorFor("os.version", osVersion, true);
            reportErrorFor("the OS type", osType, false);
            reportErrorFor("os.arch", architecture, true);
        }
    }
}
