|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.melati.util.PropertiesUtils
public final class PropertiesUtils
Useful things to do with properties files.
| Method Summary | |
|---|---|
static java.util.Properties |
fromFile(java.io.File path)
Get a Properties object from a file. |
static java.util.Properties |
fromResource(java.lang.Class clazz,
java.lang.String name)
Get a Properties object from a Class. |
static int |
getOrDefault_int(java.util.Properties properties,
java.lang.String propertyName,
int def)
Get an Integer property from a Properties object or make a fuss. |
static java.lang.String |
getOrDefault(java.util.Properties properties,
java.lang.String propertyName,
java.lang.String def)
Get a property or return the supplied default. |
static int |
getOrDie_int(java.util.Properties properties,
java.lang.String propertyName)
Get an Integer property. |
static java.lang.String |
getOrDie(java.util.Properties properties,
java.lang.String propertyName)
Return a property. |
static java.lang.Object |
instanceOfNamedClass(java.util.Properties properties,
java.lang.String propertyName,
java.lang.String interfaceClassName,
java.lang.String defaultName)
Instantiate a Class. |
static java.lang.Object |
instanceOfNamedClass(java.lang.String className,
java.lang.String interfaceClassName)
Instantiate an interface. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.util.Properties fromFile(java.io.File path)
throws java.io.IOException
Properties object from a file.
path - a File path name
Properties object
java.io.IOException - if there is a problem loading the file
public static java.util.Properties fromResource(java.lang.Class clazz,
java.lang.String name)
throws java.io.IOException
Properties object from a Class.
clazz - the Class to look upname - the property file name
Properties object
java.io.IOException - if the file cannot load or is not found
public static java.lang.String getOrDie(java.util.Properties properties,
java.lang.String propertyName)
throws NoSuchPropertyException
properties - the Properties object to look inpropertyName - the property to get
NoSuchPropertyException - if the property is not set
public static java.lang.String getOrDefault(java.util.Properties properties,
java.lang.String propertyName,
java.lang.String def)
properties - the Properties object to look inpropertyName - the property to getdef - the default to return if not found
public static int getOrDie_int(java.util.Properties properties,
java.lang.String propertyName)
throws NoSuchPropertyException,
FormatPropertyException
properties - the Properties object to look inpropertyName - the property to get
NoSuchPropertyException - if it is not found
FormatPropertyException - if it is not an Integer
public static int getOrDefault_int(java.util.Properties properties,
java.lang.String propertyName,
int def)
throws FormatPropertyException
Properties object or make a fuss.
properties - a PropertiespropertyName - the name of the propertydef - cater for multiple definitions, with increment numbers
FormatPropertyException - if it is not an Integer
public static java.lang.Object instanceOfNamedClass(java.lang.String className,
java.lang.String interfaceClassName)
throws InstantiationPropertyException
className - the name of the classinterfaceClassName - the interface Class name
InstantiationPropertyException - if the named class does not descend from the interface
public static java.lang.Object instanceOfNamedClass(java.util.Properties properties,
java.lang.String propertyName,
java.lang.String interfaceClassName,
java.lang.String defaultName)
throws InstantiationPropertyException
properties - a PropertiespropertyName - the name of the propertyinterfaceClassName - the interface namedefaultName - a default concrete class if the property is undefined
InstantiationPropertyException - if there is a problem
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||