Ejemplo n.º 1
0
        /**
         * Determines and stores the network sites to test for public network connectivity. The sites are drawn from the
         * JVM's SharpEarth.avkey.NetworkStatusTestSites property ({@link AVKey#NETWORK_STATUS_TEST_SITES}). If that
         * property is not defined, the sites are drawn from the same property in the World Wind or application
         * configuration file. If the sites are not specified there, the set of sites specified in {@link
         * #DEFAULT_NETWORK_TEST_SITES} are used. To indicate an empty list in the JVM property or configuration file
         * property, specify an empty site list, "".
         */
        protected void establishNetworkTestSites()
        {
            String testSites = System.getProperty(AVKey.NETWORK_STATUS_TEST_SITES);

            if (testSites == null)
            {
                testSites = Configuration.getStringValue(AVKey.NETWORK_STATUS_TEST_SITES);
            }

            if (testSites == null)
            {
                this.networkTestSites.addAll(Arrays.asList(DEFAULT_NETWORK_TEST_SITES));
            }
            else
            {
                String[]      sites       = testSites.split(",");
                List <String> actualSites = new ArrayList <String>(sites.length);

                for (int i = 0; i < sites.length; i++)
                {
                    String site = WWUtil.removeWhiteSpace(sites[i]);
                    if (!WWUtil.isEmpty(site))
                    {
                        actualSites.add(site);
                    }
                }

                this.setNetworkTestSites(actualSites);
            }
        }
Ejemplo n.º 2
0
        /**
         * Parses a string to a double value if the string can be parsed as a double. Does not log a message if the string
         * can not be parsed as a double.
         *
         * @param s the string to parse.
         *
         * @return the double value parsed from the string, or null if the string cannot be parsed as a double.
         */
        public static Double makeDouble(String s)
        {
            if (WWUtil.isEmpty(s))
            {
                return(null);
            }

            try
            {
                return(Double.valueOf(s));
            }
            catch (NumberFormatException e)
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /**
         * Parses a string to a double value using the current locale if the string can be parsed as a double. Does not log
         * a message if the string can not be parsed as a double.
         *
         * @param s the string to parse.
         *
         * @return the double value parsed from the string, or null if the string cannot be parsed as a double.
         */
        public static Double makeDoubleForLocale(String s)
        {
            if (WWUtil.isEmpty(s))
            {
                return(null);
            }

            try
            {
                return(NumberFormat.getInstance().parse(s.trim()).doubleValue());
            }
            catch (ParseException e)
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /**
         * Parses a string to a long value if the string can be parsed as a long. Does not log a message if the string can
         * not be parsed as a long.
         *
         * @param s the string to parse.
         *
         * @return the long value parsed from the string, or null if the string cannot be parsed as a long.
         */
        public static Long makeLong(String s)
        {
            if (WWUtil.isEmpty(s))
            {
                return(null);
            }

            try
            {
                return(Long.valueOf(s));
            }
            catch (NumberFormatException e)
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        /**
         * Parses a string to an integer value if the string can be parsed as a integer. Does not log a message if the
         * string can not be parsed as an integer.
         *
         * @param s the string to parse.
         *
         * @return the integer value parsed from the string, or null if the string cannot be parsed as an integer.
         */
        public static Integer makeInteger(String s)
        {
            if (WWUtil.isEmpty(s))
            {
                return(null);
            }

            try
            {
                return(Integer.valueOf(s));
            }
            catch (NumberFormatException e)
            {
                return(null);
            }
        }