com.palantir.opensource.sysmon.util
Class PropertiesUtils

java.lang.Object
  extended by com.palantir.opensource.sysmon.util.PropertiesUtils

public class PropertiesUtils
extends Object

A small library to make dealing with numeric values in a Properties object easier, cleaner, and type safe.


Constructor Summary
PropertiesUtils()
           
 
Method Summary
static int extractInteger(Properties p, String key, int defaultValue)
          Returns the Integer value at the specified key.
static long extractLong(Properties p, String key, long defaultValue)
          Returns the Long value at the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesUtils

public PropertiesUtils()
Method Detail

extractInteger

public static final int extractInteger(Properties p,
                                       String key,
                                       int defaultValue)
                                throws NumberFormatException
Returns the Integer value at the specified key.

Parameters:
p - Properties object to extract values from
key - key to be extracted
defaultValue - default value to use if specified key doesn't exist
Returns:
the Integer stored in the Properties object.
Throws:
NumberFormatException - if the value stored in the Properties object does not parse as an Integer.

extractLong

public static final long extractLong(Properties p,
                                     String key,
                                     long defaultValue)
                              throws NumberFormatException
Returns the Long value at the specified key.

Parameters:
p - Properties object to extract values from
key - key to be extracted
defaultValue - default value to use if specified key doesn't exist
Returns:
the Long stored in the Properties object.
Throws:
NumberFormatException - if the value stored in the Properties object does not parse as an Long.


Copyright © 2012 Palantir Technologies. All Rights Reserved.