All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.javafx.runtime.SystemProperties Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code 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.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code 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 in the LICENSE file that
 * accompanied this code).
 *
 * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package com.sun.javafx.runtime;

import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Hashtable;

public class  SystemProperties {
   /**
    * JavaFX System Properties table.
    * First column represents javafx property name with "javafx" prefix stripped off.
    * Second column represents underlying runtime platform equivalent. 
    * "jfx_specific" value in the runtime platform equivalent field indicates the property is JavaFX specific.
    * Empty string in   the runtime platform equivalent field indicates thete is no equivalent property for given platform.
    */
    private static final String[] sysprop_table = {
        /*"javafx.*/"application.codebase", "jfx_specific", /*"javafx.*/"debug", "javafx.debug"
    };


    /**
     * JavaFX Specific System Properties table.
     * First column represents javafx environment specific property name with "javafx" prefix stripped off.
     * Second column represents value of the property 
    */
    private static final String[] jfxprop_table = {
        /*"javafx.*/"application.codebase", "",
    };

    private static final Hashtable sysprop_list = new Hashtable();
    private static final Hashtable jfxprop_list = new Hashtable();

    private static final String versionResourceName =
            "/com/sun/javafx/runtime/resources/version.properties";

    private static boolean isDebug;

    static {
        AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                addProperties (sysprop_table, false);
                addProperties (jfxprop_table, true);
                setVersions();
                isDebug = "true".equalsIgnoreCase(getProperty("javafx.debug"));
                return null;
            }
        });
    }

    /*
     * Populate our well known version strings
     */
    private static void setVersions() {
        int size;
        InputStream is =
                SystemProperties.class.getResourceAsStream(versionResourceName);
        try  {
            size = is.available();
        
            byte[] b = new byte[size];
            int n = is.read(b);            
            String inStr = new String(b, "utf-8");
            SystemProperties.setFXProperty("javafx.version",
                    getValue(inStr, "release="));

            SystemProperties.setFXProperty("javafx.runtime.version",
                    getValue(inStr, "full="));

        } catch (Exception ignore) {
        }
    }
    /*
     * Returns a value given a name
     */
    private static String getValue(String toSearch, String name) {
        String s = toSearch;
        int index;
        while ((index = s.indexOf(name)) != -1) {
            s = s.substring(index);
            if ((index = s.indexOf(0x0A))!= -1) {
                return (s.substring(name.length(), index)).trim();
            }
            return (s.substring(name.length(), s.length())).trim();
        }
        return "unknown";
    }
    /**
     * Registers a statically allocated System Properties table 
     * Once registered properties listed in the table are availabe for inquiry through FX.getProperty().
     * Table is defined as a String array with JavaFX property name followed by property value or property mapping identifier
     * depending on whether the table contains JavaFX specific properties or not.
     * Note that JavaFX property names have "javafx" stripped out to optimize table lookup.
     * The following identifiers are available:
     * 

* 1. Underlying runtime platform property name. When listed, FX.getProperty() will invoke System.getProperty() * method to retrieve property value. * example: * {"version", "java.version"} *

* 2. "javafx_specific". When listed indicates there is no association between the property and underlying runtime * platform. Rather the property is JavaFX specific. In that case another table needs to be provided with values * for all JavaFX specific properties. JavaFX specific properties table is a string array containing property name * and corresponding property value. * example: * {"hw.radio", "none"} *

* 3. Empty string. When listed, the meaning there is no association between the property and underlying runtime * platform nor the property is JavaFX specific. FX.getProperty() invoked on that property returns null. * example: * {"supports.mixing", "none"} * @param table System Properties table * @param jfx_specific Indicates the table contains JavaFX specific properties */ public static void addProperties (String[] table, boolean jfx_specific) { if (table == null) return; Hashtable props; if (jfx_specific) { props = jfxprop_list; } else { props = sysprop_list; } for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy