uk.ac.starlink.hdx
Class HdxProperties

java.lang.Object
  extended by uk.ac.starlink.hdx.HdxProperties

public class HdxProperties
extends Object

Manages a collection of properties for the Hdx system. We don't have to do anything particularly elaborate here, other than manage creating a set of properties, initialised from a file in a well-known place, and defaulting to the system properties.

We initialise properties from the property file named by the system property Hdx.properties, or if that does not exist, from the file Hdx.properties located in the current directory (System property user.dir).

The interface here is patterned after the property methods on the System object.


Method Summary
static Properties getProperties()
          Determines the current Hdx properties.
static String getProperty(String key)
          Gets the Hdx property indicated by the specified key.
static String getProperty(String key, String def)
          Gets the Hdx property indicated by the specified key.
static String setProperty(String key, String value)
          Sets the Hdx property indicated by the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProperties

public static Properties getProperties()
Determines the current Hdx properties.

The current set of system properties for use by the getProperty(java.lang.String) method is returned as a Properties object.

If there is no current set of Hdx properties (that is, this method is being invoked for the first time), a set of Hdx properties is first created and initialized. In all cases, the Hdx properties are defaulted by the System properties.

Returns:
a Properties object containing all the Hdx properties

getProperty

public static String getProperty(String key)
Gets the Hdx property indicated by the specified key. If there is no specifically Hdx property with this name, then return any System property with this name.

If there is no current set of Hdx properties, a set of properties is first created and initialized in the same manner as described above.

Unlike the corresponding method on System, this method throws no exceptions, and simply returns null on any error.

Parameters:
key - the name of the Hdx property
Returns:
the string value of the Hdx property, or null if there is no property with that key.

getProperty

public static String getProperty(String key,
                                 String def)
Gets the Hdx property indicated by the specified key. If there is no specifically Hdx property with this name, then return any System property with this name.

If there is no current set of Hdx properties, a set of properties is first created and initialized in the same manner as described above.

Unlike the corresponding method on System, this method throws no exceptions, and simply returns null on any error.

Parameters:
key - the name of the Hdx property
def - a default value
Returns:
the string value of the Hdx property, or null if there is no property with that key.

setProperty

public static String setProperty(String key,
                                 String value)
                          throws HdxException
Sets the Hdx property indicated by the specified key.

Unlike the corresponding method on System, this method throws only HdxException on any error.

Parameters:
key - the name of the Hdx property
value - the value of the Hdx property
Returns:
the previous value of the Hdx property, or null if it did not have one.
Throws:
HdxException - on any error


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.