edu.rit.device
Class DeviceProperties

java.lang.Object
  extended by edu.rit.device.DeviceProperties

public class DeviceProperties
extends Object

Class DeviceProperties provides access to properties that are used to configure the device. The properties are as follows:

To get the value of a given property, the program first searches for the property name in the Java system properties by calling System.getProperty(). If not found there, the program searches for the property name in the device properties file (see below). If not found there, the program throws an exception to indicate the property cannot be found. Thus, property values specified with the -D option on the java command line override property values in the device properties file.

To find the device properties file, the program searches for the following files, in order, stopping as soon as it finds one:

If the device properties file cannot be found, the M2MI Layer thows an exception.

The device properties file obeys the format specified in class java.util.Properties.

To run the program, all the properties listed above (other than edu.rit.device.properties) must be defined, either as system properties, or in the device properties file. There are no default values.

Here is an example of a device properties file. If you use this example, be sure to change the value of edu.rit.device.id.

 # Device Properties File
 
 # Globally unique device ID (hexadecimal integer, 000000000000 .. 3FFFFFFFFFFF)
 edu.rit.device.id = 00087443BC87
 


Method Summary
static long getDeviceID()
          Returns the device ID, property edu.rit.device.id.
static long getLongProperty(String name, int base, long lb, long ub, String valueErrMsg, String formatErrMsg)
          Get the long-valued device property with the given name.
static String getPropertyValue(String name)
          Get the value of the device property with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDeviceID

public static long getDeviceID()
Returns the device ID, property edu.rit.device.id.

Throws:
DevicePropertyFileException - (unchecked exception) Thrown if the device properties file cannot be found or cannot be read.
DevicePropertyMissingException - (unchecked exception) Thrown if the property value cannot be found.
DevicePropertyValueException - (unchecked exception) Thrown if the property value is not a hexadecimal integer in the range 000000000000 through 3FFFFFFFFFFF.

getLongProperty

public static long getLongProperty(String name,
                                   int base,
                                   long lb,
                                   long ub,
                                   String valueErrMsg,
                                   String formatErrMsg)
Get the long-valued device property with the given name.

Parameters:
name - Property name.
base - Number base (10 = decimal, 16 = hexadecimal).
lb - Lower bound value.
ub - Upper bound value.
valueErrMsg - Message for a value error.
formatErrMsg - Message for a format error.
Throws:
DevicePropertyFileException - (unchecked exception) Thrown if the device properties file cannot be found or cannot be read.
DevicePropertyMissingException - (unchecked exception) Thrown if the property value cannot be found.
DevicePropertyValueException - (unchecked exception) Thrown if the property value is illegal.

getPropertyValue

public static String getPropertyValue(String name)
Get the value of the device property with the given name.

Parameters:
name - Property name.
Returns:
String value of the property.
Throws:
DevicePropertyFileException - (unchecked exception) Thrown if the device properties file cannot be found or cannot be read.
DevicePropertyMissingException - (unchecked exception) Thrown if the property value cannot be found.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.