|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
org.biojava.utils.TypedProperties
public class TypedProperties
a sub-class of java.util.Properties that provides the same constructors, adds two convenient load methods to load the properties from files and, most importantly, adds getPropertyAsXXX() methods to get a property as an object of type XXX.
Field Summary | |
---|---|
static String |
DEFAULT_DELIMITERS
the default string of delimiter characters used by getAsStringList() |
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
TypedProperties()
Creates an empty property list with no default values. |
|
TypedProperties(Properties defaults)
Creates an empty property list with the specified defaults. |
Method Summary | |
---|---|
Object |
clone()
|
boolean |
equals(Object o)
|
Boolean |
getPropertyAsBoolean(String key)
Searches for the property with the specified key in this property list. |
Double |
getPropertyAsDouble(String key)
Searches for the property with the specified key in this property list. |
Integer |
getPropertyAsInteger(String key)
Searches for the property with the specified key in this property list. |
Long |
getPropertyAsLong(String key)
Searches for the property with the specified key in this property list. |
List |
getPropertyAsStringList(String key)
just like getPropertyAsStringList(String key, String delims) but uses ',' (comma), ';' (semicolon) and '\t' (tab) as the possible delimiters. |
List |
getPropertyAsStringList(String key,
String delims)
Searches for the property with the specified key in this property list. |
int |
hashCode()
|
void |
load(Class clazz,
String resourceName)
Reads a property list (key and element pairs) from the given file which is interpreted as a resource of the given class. |
void |
load(String fileName)
Reads a property list (key and element pairs) from the file with the given file name. |
String |
toString()
|
Methods inherited from class java.util.Properties |
---|
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, save, setProperty, store, storeToXML, storeToXML |
Methods inherited from class java.util.Hashtable |
---|
clear, contains, containsKey, containsValue, elements, entrySet, get, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_DELIMITERS
Constructor Detail |
---|
public TypedProperties()
public TypedProperties(Properties defaults)
defaults
- the defaults.Method Detail |
---|
public void load(String fileName) throws FileNotFoundException, IOException
fileName
- the file name. Not null.
FileNotFoundException
- if the file does not exist, is a directory rather than a regular file, or for some
other reason cannot be opened for reading.
IOException
- if an error occurred when reading from the input stream created from the file with the given
name.public void load(Class clazz, String resourceName) throws IOException
clazz
- the class with which the resource identified by resourceName
is taken to be associated with
(java.lang.Class.getResourceAsStream() on this Class
object is used to load the resource). If clazz is null, the
resource is considered to be a system resource, and
java.lang.ClassLoader.getSystemResourceAsStream() is used to
load the resource.resourceName
- the name of the resource from which to load the properties. It is a precondition that the
resource with this name exists (regardless whether it is interpreted as a system resource or a
class resource), otherwise an IllegalArgumentException is thrown.
IOException
- if an error occurred when reading from the input stream created from the given resource.Class
,
ClassLoader
public Integer getPropertyAsInteger(String key) throws NumberFormatException
key
- the property key.
NumberFormatException
- if the property associated with the given key does not have an integer value.public Long getPropertyAsLong(String key) throws NumberFormatException
key
- the property key.
NumberFormatException
- if the property associated with the given key does not have an integer value.public Double getPropertyAsDouble(String key) throws NumberFormatException
key
- the property key.
NumberFormatException
- if the property associated with the given key does not have an integer value.public Boolean getPropertyAsBoolean(String key) throws RuntimeException
If the property value is equal, ignoring case, to the string "true" or "yes" then the boolean value returned from this method is true. If the property value is equal, ignoring case, to the string "false" or "no" then the boolean value returned from this method is false.
key
- the property key.
RuntimeException
- if the property associated with the given key does not have an integer value.public List getPropertyAsStringList(String key, String delims)
The property value is interpreted as String objects (tokens) separated by one or more (consecutive) separator characters taken from the delims string. Any of these characters separates the tokens and can hence not be part of any token! The tokens identified in this way are put into a List in the order in which they appear in the property value. White space at the beginning and end of each token are removed before storing the token as an element of the list (this includes white space at the beginning and end of the complete property value)! Empty strings are also never added to the list, i.e. if after removal of white space from a token a token is the empty string, it is not stored in the list! All this results in a very natural conversion of the property value into a list of strings: only "real" (non-white-space, non-white-space-bounded, non-delimiter-containing) sub-strings from the property value are put as string elements into the list.
key
- the property key.delims
- the string of allowed delimiter characters (not null and not empty).
public List getPropertyAsStringList(String key)
public String toString()
toString
in class Hashtable<Object,Object>
public boolean equals(Object o)
equals
in interface Map<Object,Object>
equals
in class Hashtable<Object,Object>
public int hashCode()
hashCode
in interface Map<Object,Object>
hashCode
in class Hashtable<Object,Object>
public Object clone()
clone
in class Hashtable<Object,Object>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |