NASA World Wind

gov.nasa.worldwind
Class Configuration

java.lang.Object
  extended by gov.nasa.worldwind.Configuration

public class Configuration
extends java.lang.Object

This class manages the initial World Wind configuration. It reads World Wind configuration files and registers their contents. Configurations files contain the names of classes to create at run-time, the initial model definition, including the globe, elevation model and layers, and various control quantities such as cache sizes and data retrieval timeouts.

The Configuration class is a singleton, but its instance is not exposed publicly. It is addressed only via static methods of the class. It is constructed upon first use of any of its static methods.

When the Configuration class is first instantiated it reads the XML document config/worldwind.xml and registers all the information there. The information can subsequently be retrieved via the class' various getValue methods. Many World Wind start-up objects query this information to determine the classes to create. For example, the first World Wind object created by an application is typically a WorldWindowGLCanvas. During construction that class causes World Wind's internal classes to be constructed, using the names of those classes drawn from the Configuration singleton, this class.

The default World Wind configuration document is config/worldwind.xml. This can be changed by setting the Java property gov.nasa.worldwind.config.file to a different file name or a valid URL prior to creating any World Wind object or invoking any static methods of World Wind classes, including the Configuration class. When an application specifies a different configuration location it typically does so in its main method prior to using World Wind. If a file is specified its location must be on the classpath. (The contents of application and World Wind jar files are typically on the classpath, in which case the configuration file may be in the jar file.)

Additionally, an application may set another Java property, gov.nasa.worldwind.app.config.document, to a file name or URL whose contents contain configuration values to override those of the primary configuration document. World Wind overrides only those values in this application document, it leaves all others to the value specified in the primary document. Applications usually specify an override document in order to specify the initial layers in the model.

See config/worldwind.xml for documentation on setting configuration values.

Configuration values can also be set programatically via setValue(String, Object), but they are not retroactive so affect only Configuration queries made subsequent to setting the value.

Note: Prior to September of 2009, configuration properties were read from the file config/worldwind.properties. An alternate file could be specified via the gov.nasa.worldwind.config.file Java property. These mechanisms remain available but are deprecated. World Wind no longer contains a worldwind.properties file. If worldwind.properties or its replacement as specified through the Java property exists at run-time and can be found via the classpath, configuration values specified by that mechanism are given precedence over values specified by the new mechanism.


Field Summary
static java.lang.String DEFAULT_LOGGER_NAME
           
 
Method Summary
static java.lang.String getCurrentWorkingDirectory()
          Returns the path to the application's current working directory.
static java.lang.Double getDoubleValue(java.lang.String key)
          Return as an Double the value associated with a specified key.
static java.lang.Double getDoubleValue(java.lang.String key, java.lang.Double defaultValue)
          Return as an Double the value associated with a specified key.
static org.w3c.dom.Element getElement(java.lang.String xpathExpression)
          Returns a specified element of an XML configuration document.
static java.lang.Integer getIntegerValue(java.lang.String key)
          Return as an Integer the value associated with a specified key.
static java.lang.Integer getIntegerValue(java.lang.String key, java.lang.Integer defaultValue)
          Return as an Integer the value associated with a specified key.
static float getJavaVersion()
          Returns the version of the Java virtual machine.
static java.lang.Long getLongValue(java.lang.String key)
          Return as an Long the value associated with a specified key.
static java.lang.Long getLongValue(java.lang.String key, java.lang.Long defaultValue)
          Return as an Long the value associated with a specified key.
static java.lang.String getStringValue(java.lang.String key)
          Return as a string the value associated with a specified key.
static java.lang.String getStringValue(java.lang.String key, java.lang.String defaultValue)
          Return as a string the value associated with a specified key.
static java.lang.String getSystemTempDirectory()
          Returns the path to the operating system's temp directory.
static java.lang.String getUserHomeDirectory()
          Returns the path to the application user's home directory.
static boolean hasKey(java.lang.String key)
          Determines whether a key exists in the configuration.
static void insertConfigurationDocument(java.lang.String fileName)
           
static boolean isLinuxOS()
          Determines whether the operating system is Linux operating system.
static boolean isMacOS()
          Determines whether the operating system is a Mac operating system.
static boolean isSolarisOS()
          Determines whether the operating system is Solaris operating system.
static boolean isUnixOS()
          Determines whether the operating system is Unix operating system.
static boolean isWindowsOS()
          Determines whether the operating system is Windows operating system.
static boolean isWindowsVistaOS()
          Determines whether the operating system is Windows Vista operating system.
static boolean isWindowsXPOS()
          Determines whether the operating system is Windows XP operating system.
static void removeKey(java.lang.String key)
          Removes a key and its value from the configuration if the configuration contains the key.
static void setValue(java.lang.String key, java.lang.Object value)
          Adds a key and value to the configuration, or changes the value associated with the key if the key is already in the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOGGER_NAME

public static final java.lang.String DEFAULT_LOGGER_NAME
See Also:
Constant Field Values
Method Detail

getCurrentWorkingDirectory

public static java.lang.String getCurrentWorkingDirectory()
Returns the path to the application's current working directory.

Returns:
the absolute path to the application's current working directory.

getDoubleValue

public static java.lang.Double getDoubleValue(java.lang.String key)
Return as an Double the value associated with a specified key.

Parameters:
key - the key for the desired value.
Returns:
the value associated with the key, or null if the key does not exist or is not an Double or string representation of an Double.

getDoubleValue

public static java.lang.Double getDoubleValue(java.lang.String key,
                                              java.lang.Double defaultValue)
Return as an Double the value associated with a specified key.

Parameters:
key - the key for the desired value.
defaultValue - the value to return if the key does not exist.
Returns:
the value associated with the key, or the specified default value if the key does not exist or is not an Double or string representation of an Double.

getElement

public static org.w3c.dom.Element getElement(java.lang.String xpathExpression)
Returns a specified element of an XML configuration document.

Parameters:
xpathExpression - an XPath expression identifying the element of interest.
Returns:
the element of interest if the XPath expression is valid and the element exists, otherwise null.
Throws:
java.lang.NullPointerException - if the XPath expression is null.

getIntegerValue

public static java.lang.Integer getIntegerValue(java.lang.String key)
Return as an Integer the value associated with a specified key.

Parameters:
key - the key for the desired value.
Returns:
the value associated with the key, or null if the key does not exist or is not an Integer or string representation of an Integer.

getIntegerValue

public static java.lang.Integer getIntegerValue(java.lang.String key,
                                                java.lang.Integer defaultValue)
Return as an Integer the value associated with a specified key.

Parameters:
key - the key for the desired value.
defaultValue - the value to return if the key does not exist.
Returns:
the value associated with the key, or the specified default value if the key does not exist or is not an Integer or string representation of an Integer.

getJavaVersion

public static float getJavaVersion()
Returns the version of the Java virtual machine.

Returns:
the Java virtual machine version.

getLongValue

public static java.lang.Long getLongValue(java.lang.String key)
Return as an Long the value associated with a specified key.

Parameters:
key - the key for the desired value.
Returns:
the value associated with the key, or null if the key does not exist or is not a Long or string representation of a Long.

getLongValue

public static java.lang.Long getLongValue(java.lang.String key,
                                          java.lang.Long defaultValue)
Return as an Long the value associated with a specified key.

Parameters:
key - the key for the desired value.
defaultValue - the value to return if the key does not exist.
Returns:
the value associated with the key, or the specified default value if the key does not exist or is not a Long or string representation of a Long.

getStringValue

public static java.lang.String getStringValue(java.lang.String key)
Return as a string the value associated with a specified key.

Parameters:
key - the key for the desired value.
Returns:
the value associated with the key, or null if the key does not exist.

getStringValue

public static java.lang.String getStringValue(java.lang.String key,
                                              java.lang.String defaultValue)
Return as a string the value associated with a specified key.

Parameters:
key - the key for the desired value.
defaultValue - the value to return if the key does not exist.
Returns:
the value associated with the key, or the specified default value if the key does not exist.

getSystemTempDirectory

public static java.lang.String getSystemTempDirectory()
Returns the path to the operating system's temp directory.

Returns:
the absolute path to the operating system's tempopory directory.

getUserHomeDirectory

public static java.lang.String getUserHomeDirectory()
Returns the path to the application user's home directory.

Returns:
the absolute path to the application user's home directory.

hasKey

public static boolean hasKey(java.lang.String key)
Determines whether a key exists in the configuration.

Parameters:
key - the key of interest.
Returns:
true if the key exists, otherwise false.

insertConfigurationDocument

public static void insertConfigurationDocument(java.lang.String fileName)

isLinuxOS

public static boolean isLinuxOS()
Determines whether the operating system is Linux operating system.

Returns:
true if the operating system is a Linux operating system, otherwise false.

isMacOS

public static boolean isMacOS()
Determines whether the operating system is a Mac operating system.

Returns:
true if the operating system is a Mac operating system, otherwise false.

isSolarisOS

public static boolean isSolarisOS()
Determines whether the operating system is Solaris operating system.

Returns:
true if the operating system is a Solaris operating system, otherwise false.

isUnixOS

public static boolean isUnixOS()
Determines whether the operating system is Unix operating system.

Returns:
true if the operating system is a Unix operating system, otherwise false.

isWindowsOS

public static boolean isWindowsOS()
Determines whether the operating system is Windows operating system.

Returns:
true if the operating system is a Windows operating system, otherwise false.

isWindowsVistaOS

public static boolean isWindowsVistaOS()
Determines whether the operating system is Windows Vista operating system.

Returns:
true if the operating system is a Windows Vista operating system, otherwise false.

isWindowsXPOS

public static boolean isWindowsXPOS()
Determines whether the operating system is Windows XP operating system.

Returns:
true if the operating system is a Windows XP operating system, otherwise false.

removeKey

public static void removeKey(java.lang.String key)
Removes a key and its value from the configuration if the configuration contains the key.

Parameters:
key - the key of interest.

setValue

public static void setValue(java.lang.String key,
                            java.lang.Object value)
Adds a key and value to the configuration, or changes the value associated with the key if the key is already in the configuration.

Parameters:
key - the key to set.
value - the value to associate with the key.

NASA World Wind