baseplatforminfo.java.svn-base

来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 153 行

SVN-BASE
153
字号
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tck.j2me.platform;import com.sun.javatest.TestEnvironment;/** * Class that encapsulates information about underlying platform under test, * as configured in the interview. */public abstract class BasePlatformInfo {    /**     * CLDC platform.     */    public static final String CLDC_PLATFORM = "cldc";    /**     * MIDP platform.     */    public static final String MIDP_PLATFORM = "midp";    /**     * CDC platform.     */    public static final String CDC_PLATFORM = "cdc";    /**     * A key to lookup platform information in the test environment.     */    public static final String PLATFORM_KEY = "baseConfiguration";    private BasePlatformInfo() {        // nobody should be able to create instances    }    /**     * Determines whether MIDP mode is selected     * in the interview.     *     * @return <code>true</code> if and only if MIDP mode is selected     * in the interview.     */    public abstract boolean isMidp();    /**     * Determines whether CLDC mode is selected     * in the interview.     *     * @return <code>true</code> if and only if CLDC mode is selected     * in the interview.     */    public abstract boolean isCldc();    /**     * Determines whether CDC mode is selected     * in the interview.     *     * @return <code>true</code> if and only if CDC mode is selected     * in the interview.     */    public abstract boolean isCdc();    /**     * Provides selected platform's name.     *     * @return The name of selected platform.     * @see #CLDC_PLATFORM     * @see #MIDP_PLATFORM     * @see #CDC_PLATFORM     */    public abstract String getPlatformName();    /**     * Creates PlatformInfo instance, with data loaded from the test     * environment.     * <p>     * May return <code>null</code> if the base platform is undefined or     * misconfigured in the interview.     *     * @param env     *            The test environment.     * @return BasePlatform instance.     */    public static BasePlatformInfo fromEnv(final TestEnvironment env) {        String platformName = null;        try {            String[] envData = env.lookup(PLATFORM_KEY);            if (envData != null && envData.length == 1) {                platformName = envData[0];            }        } catch (TestEnvironment.Fault e) {            // do nothing        }        if (platformName == null) {            return null;        }        return new DefaultPlatformInfo(platformName);    }    private static class DefaultPlatformInfo extends BasePlatformInfo {        private String platformName;        DefaultPlatformInfo(String platformName) {            this.platformName = platformName;        }        public String getPlatformName() {            return platformName;        }        public boolean isMidp() {            return MIDP_PLATFORM.equalsIgnoreCase(getPlatformName());        }        public boolean isCldc() {            return CLDC_PLATFORM.equalsIgnoreCase(getPlatformName())                    || "CUSTOM_CLDC".equalsIgnoreCase(getPlatformName());        }        public boolean isCdc() {                return CDC_PLATFORM.equalsIgnoreCase(getPlatformName());        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?