org.sapia.ubik.rmi
Class PropUtil

java.lang.Object
  extended by org.sapia.ubik.rmi.PropUtil

public class PropUtil
extends java.lang.Object

This class provides utility methods over a list of Properties object that are sequentially looked up for given values.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2005 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
PropUtil()
           
 
Method Summary
 PropUtil addProperties(java.util.Properties props)
           
 boolean getBooleanProperty(java.lang.String key)
           
 boolean getBooleanProperty(java.lang.String key, boolean defaultValue)
           
 float getFloat(java.lang.String key, float defaultValue)
           
 float getFloatProperty(java.lang.String key)
           
 int getIntProperty(java.lang.String key)
           
 int getIntProperty(java.lang.String key, int defaultValue)
           
 long getLongProperty(java.lang.String key)
           
 long getLongProperty(java.lang.String key, long defaultValue)
           
 java.lang.String getProperty(java.lang.String key)
           
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropUtil

public PropUtil()
Method Detail

addProperties

public PropUtil addProperties(java.util.Properties props)
Parameters:
props - some Properties to look up.
Returns:
this instance.

getIntProperty

public int getIntProperty(java.lang.String key)
                   throws java.lang.NumberFormatException,
                          java.lang.IllegalArgumentException
Parameters:
key - the key of the desired property.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to an integer.
java.lang.IllegalArgumentException - if no property exists for the given key.

getIntProperty

public int getIntProperty(java.lang.String key,
                          int defaultValue)
                   throws java.lang.NumberFormatException
Parameters:
key - the key of the desired property.
defaultValue - the default value that must be returned if not property was found for the given key.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to an integer.

getLongProperty

public long getLongProperty(java.lang.String key)
                     throws java.lang.NumberFormatException,
                            java.lang.IllegalArgumentException
Parameters:
key - the key of the desired property.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to a long.
java.lang.IllegalArgumentException - if no property exists for the given key.

getLongProperty

public long getLongProperty(java.lang.String key,
                            long defaultValue)
                     throws java.lang.NumberFormatException
Parameters:
key - the key of the desired property.
defaultValue - the default value that must be returned if not property was found for the given key.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to a long.

getFloatProperty

public float getFloatProperty(java.lang.String key)
                       throws java.lang.NumberFormatException,
                              java.lang.IllegalArgumentException
Parameters:
key - the key of the desired property.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to a float.
java.lang.IllegalArgumentException - if no property exists for the given key.

getFloat

public float getFloat(java.lang.String key,
                      float defaultValue)
               throws java.lang.NumberFormatException
Parameters:
key - the key of the desired property.
defaultValue - the default value that must be returned if not property was found for the given key.
Returns:
the property value.
Throws:
java.lang.NumberFormatException - if the value could not be converted to a float.

getBooleanProperty

public boolean getBooleanProperty(java.lang.String key)
Parameters:
key - the key of the desired property
Returns:
true if the value corresponding to the given key equals true, on, or yes, false otherwise, or if no value could be found for the given key.

getBooleanProperty

public boolean getBooleanProperty(java.lang.String key,
                                  boolean defaultValue)
Parameters:
key - the key of the desired property
Returns:
true if the value corresponding to the given key equals true, on, or yes, false otherwise, or the passed in default if no value could be found for the given key.

getProperty

public java.lang.String getProperty(java.lang.String key)
Parameters:
key - the key of the desired property.
Returns:
the value corresponding to the given key, or null if no such value exists.

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Parameters:
key - the key of the desired property.
Returns:
the value corresponding to the given key, or the given default value of the desired property was not found.


Copyright © 2010 Sapia OSS. All Rights Reserved.