com.hangum.tadpole.sql.query.TadpoleSystemChecker.java Source code

Java tutorial

Introduction

Here is the source code for com.hangum.tadpole.sql.query.TadpoleSystemChecker.java

Source

/*******************************************************************************
 * Copyright (c) 2014 hangum.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     hangum - initial API and implementation
 ******************************************************************************/
package com.hangum.tadpole.sql.query;

import org.apache.commons.lang.StringUtils;

import com.hangum.tadpole.sql.Messages;

/**
 * Tadpole System checker
 * ? ? ? . 
 * ??  ??,    ?? . 
 * 
 * 1. ?  jvm 1.7??  ?  1.6 ?? ?? .
 *
 * @author hangum
 * @deprecated java 1.7 ??  ???  .
 *
 */
public class TadpoleSystemChecker {

    private static final String OS = System.getProperty("os.name"); //$NON-NLS-1$
    private static final String JAVA_VERSION = System.getProperty("java.version"); //$NON-NLS-1$

    /**
     * ? ?  ? . 
     * 
     * @return
     */
    public static void checker() throws Exception {
        double dblJavaVersion = Double.parseDouble(JAVA_VERSION.substring(0, 3));

        // mac ? jvm 1.7 ?? ? .
        if (isMac()) {
            if (dblJavaVersion < 1.7d) {
                throw new Exception(String.format(Messages.TadpoleSystemChecker_2, "1.7.x")); //$NON-NLS-2$
            }

            //  ??  1.6 ??? . 
        } else {
            if (dblJavaVersion < 1.6d) {
                throw new Exception(String.format(Messages.TadpoleSystemChecker_2, "1.6.x")); //$NON-NLS-2$
            }
        }
    }

    /**
     * is mac
     * @return
     */
    private static boolean isMac() {
        return StringUtils.containsIgnoreCase(OS, "mac"); //$NON-NLS-1$
    }
}