ibis.util
Class TypedProperties

java.lang.Object
  extended byibis.util.TypedProperties

public class TypedProperties
extends java.lang.Object

Utility to extract some typed system properties.


Method Summary
static boolean booleanProperty(java.lang.String name)
          Returns true if property name is defined and has a value that is conventionally associated with 'true' (as in Ant): any of 1, on, true, yes.
static boolean booleanProperty(java.lang.String name, boolean defaultVal)
          Returns true if property name has a value that is conventionally associated with 'true' (as in Ant): any of 1, on, true, yes.
static void checkProperties(java.lang.String prefix, java.lang.String[] propnames, java.lang.String[] excludes)
          Check validity of a System property.
static int intProperty(java.lang.String name)
          Returns the integer value of property
static int intProperty(java.lang.String name, int dflt)
          Returns the integer value of property
static long longProperty(java.lang.String name)
          Returns the long value of property
static long longProperty(java.lang.String name, long dflt)
          Returns the long value of property
static java.lang.String stringProperty(java.lang.String name)
          Get value of property
static java.lang.String stringProperty(java.lang.String name, java.lang.String dflt)
          Get value of property
static boolean stringPropertyMatch(java.lang.String name, java.lang.String match)
          Returns true if property name is defined and has a string value that equals match.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

booleanProperty

public static boolean booleanProperty(java.lang.String name)
Returns true if property name is defined and has a value that is conventionally associated with 'true' (as in Ant): any of 1, on, true, yes.

Parameters:
name - property name
Returns:
true if property is defined and set

booleanProperty

public static boolean booleanProperty(java.lang.String name,
                                      boolean defaultVal)
Returns true if property name has a value that is conventionally associated with 'true' (as in Ant): any of 1, on, true, yes. If the property is not defined, return the specified default value.

Parameters:
name - property name
defaultVal - the value that is returned if the property is absent
Returns:
true if property is defined and set

intProperty

public static int intProperty(java.lang.String name)
Returns the integer value of property

Parameters:
name - property name
Returns:
the integer value of property
Throws:
java.lang.NumberFormatException - if the property is undefined or not an integer

intProperty

public static int intProperty(java.lang.String name,
                              int dflt)
Returns the integer value of property

Parameters:
name - property name
dflt - default value if the property is undefined
Returns:
the integer value of property
Throws:
java.lang.NumberFormatException - if the property defined and not an integer

longProperty

public static long longProperty(java.lang.String name)
Returns the long value of property

Parameters:
name - property name
Returns:
the long value of property
Throws:
java.lang.NumberFormatException - if the property is undefined or not a long

longProperty

public static long longProperty(java.lang.String name,
                                long dflt)
Returns the long value of property

Parameters:
name - property name
dflt - default value if the property is undefined
Returns:
the long value of property
Throws:
java.lang.NumberFormatException - if the property defined and not a long

stringPropertyMatch

public static boolean stringPropertyMatch(java.lang.String name,
                                          java.lang.String match)
Returns true if property name is defined and has a string value that equals match.

Parameters:
name - property name
match - value to be matched
Returns:
true if property is defined and equals match

stringProperty

public static java.lang.String stringProperty(java.lang.String name)
Get value of property

Parameters:
name - property name
Returns:
the value of the property or null if it is not set

stringProperty

public static java.lang.String stringProperty(java.lang.String name,
                                              java.lang.String dflt)
Get value of property

Parameters:
name - property name
Returns:
the value of the property or null if it is not set

checkProperties

public static void checkProperties(java.lang.String prefix,
                                   java.lang.String[] propnames,
                                   java.lang.String[] excludes)
Check validity of a System property. All system properties are checked; when the name starts with the specified prefix, it should be in the specified list of property names, unless it starts with one of the exclude members. If the property is not found, a warning is printed.

Parameters:
prefix - prefix of checked property names, for instance "satin.".
propnames - list of accepted property names.
excludes - list of property prefixes that should not be checked.


The Ibis project