org.mbari.siam.core
Class SiamProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by org.mbari.siam.core.SiamProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>
Direct Known Subclasses:
NodeProperties

public class SiamProperties
extends java.util.Properties

SiamProperties extends java.util.Properties, with more robust parsing of keys and values.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
SiamProperties()
           
 
Method Summary
 ChannelRange[] getChannelRangeProperty(java.lang.String key)
          Searches for the integer range property with specified key.
 int[] getIntegerArrayProperty(java.lang.String key)
          Searches for the property with specified key, where the value contains an array of integers.
 int getIntegerProperty(java.lang.String key)
          Searches for the integer property with specified key.
 int getIntegerProperty(java.lang.String key, int defaultValue)
          Searches for the integer property with specified key.
 long getLongProperty(java.lang.String key)
          Searches for the long integer property with specified key.
 long getLongProperty(java.lang.String key, long defaultValue)
          Searches for the long integer property with specified key.
 int getNonNegativeIntegerProperty(java.lang.String key)
           
 java.lang.String getProperty(java.lang.String key)
          Searches for the property with specified key.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Searches for the property with specified key.
 java.lang.String getRequiredProperty(java.lang.String key)
          Get value of specified property; throw MissingPropertyException if not found.
 java.lang.String[] getStringArrayProperty(java.lang.String key, java.lang.String[] validValues, java.lang.String delimiter)
          Searches for the property with specified key, where the value contains an array of Strings.
 ChannelRange[] parseChannelRangeProperty(java.lang.String rangeStr)
           
protected  int parseInteger(java.lang.String s)
          Performs an Integer.parseInt(), but allows hexadecimal beginning with "0x"
 java.lang.String[] parseStringArrayProperty(java.lang.String inStr, java.lang.String[] validValues, java.lang.String delimiter)
           
 
Methods inherited from class java.util.Properties
list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SiamProperties

public SiamProperties()
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String key)
Searches for the property with specified key. Trailing whitespace is trimmed from returned value.

Overrides:
getProperty in class java.util.Properties

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Searches for the property with specified key. If the property key is not found, then defaultValue is returned. Trailing whitespace is trimmed from returned value.

Overrides:
getProperty in class java.util.Properties

getRequiredProperty

public java.lang.String getRequiredProperty(java.lang.String key)
                                     throws MissingPropertyException
Get value of specified property; throw MissingPropertyException if not found.

Throws:
MissingPropertyException

parseInteger

protected int parseInteger(java.lang.String s)
                    throws java.lang.NumberFormatException
Performs an Integer.parseInt(), but allows hexadecimal beginning with "0x"

Throws:
java.lang.NumberFormatException

getIntegerProperty

public int getIntegerProperty(java.lang.String key)
                       throws MissingPropertyException,
                              InvalidPropertyException
Searches for the integer property with specified key. Throws InvalidPropertyException if property is not an integer value. Throws MissingPropertyException if property not found

Throws:
MissingPropertyException
InvalidPropertyException

getIntegerProperty

public int getIntegerProperty(java.lang.String key,
                              int defaultValue)
Searches for the integer property with specified key. If the property key is not found or is not a valid integer, then defaultValue is returned.


getChannelRangeProperty

public ChannelRange[] getChannelRangeProperty(java.lang.String key)
                                       throws MissingPropertyException,
                                              InvalidPropertyException
Searches for the integer range property with specified key. Integer ranges are sets of (possibly) non-contiguous integer values, expressed using a comma and dash syntax, e.g.: 2-5,11,13-15 (==2,3,4,5,11,13,14,15)

Throws:
MissingPropertyException
InvalidPropertyException

parseChannelRangeProperty

public ChannelRange[] parseChannelRangeProperty(java.lang.String rangeStr)
                                         throws MissingPropertyException,
                                                InvalidPropertyException
Throws:
MissingPropertyException
InvalidPropertyException

getNonNegativeIntegerProperty

public int getNonNegativeIntegerProperty(java.lang.String key)
                                  throws MissingPropertyException,
                                         InvalidPropertyException
Throws:
MissingPropertyException
InvalidPropertyException

getLongProperty

public long getLongProperty(java.lang.String key)
                     throws MissingPropertyException,
                            InvalidPropertyException
Searches for the long integer property with specified key. Throws InvalidPropertyException if property is not an integer value. Throws MissingPropertyException if property not found

Throws:
MissingPropertyException
InvalidPropertyException

getLongProperty

public long getLongProperty(java.lang.String key,
                            long defaultValue)
Searches for the long integer property with specified key. If the property key is not found or is not a valid integer, then defaultValue is returned.


getIntegerArrayProperty

public int[] getIntegerArrayProperty(java.lang.String key)
                              throws MissingPropertyException,
                                     InvalidPropertyException
Searches for the property with specified key, where the value contains an array of integers. Throws InvalidPropertyException if any value is not an integer. Throws MissingPropertyException if property not found or is null.

For example: analogPort12 = 0 0 4 100 10 #returns 5 integers

Throws:
MissingPropertyException
InvalidPropertyException

getStringArrayProperty

public java.lang.String[] getStringArrayProperty(java.lang.String key,
                                                 java.lang.String[] validValues,
                                                 java.lang.String delimiter)
                                          throws MissingPropertyException,
                                                 InvalidPropertyException
Searches for the property with specified key, where the value contains an array of Strings. Throws InvalidPropertyException if any value is not a String the Vector validValues; if validValues is null, any values are OK. Throws MissingPropertyException if property not found or is null.

For example: platformAnalogTypes = foo bar baz # returns 3 Strings

Throws:
MissingPropertyException
InvalidPropertyException

parseStringArrayProperty

public java.lang.String[] parseStringArrayProperty(java.lang.String inStr,
                                                   java.lang.String[] validValues,
                                                   java.lang.String delimiter)
                                            throws MissingPropertyException,
                                                   InvalidPropertyException
Throws:
MissingPropertyException
InvalidPropertyException


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.