Version: ${maven.project.version}

org.soaplab.services.metadata
Class PropertiesBag

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.String,java.lang.Object>
          extended by org.soaplab.services.metadata.PropertiesBag
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>

public class PropertiesBag
extends java.util.Hashtable<java.lang.String,java.lang.Object>

A simple extension of java.util.Hashtable bringing more methods for checking and retrieving properties. It is also the place where we can later add case-insensitive handling of keys.

Version:
$Id: PropertiesBag.java,v 1.3 2007/04/19 22:17:06 marsenger Exp $
Author:
Martin Senger
See Also:
Serialized Form

Constructor Summary
PropertiesBag()
          An empty constructor.
PropertiesBag(java.lang.String[] props)
          Create a bag initialized with 'props'.
PropertiesBag(java.lang.String propName, java.lang.String propValue)
          A convenient constructor for creating a bag with exactly one property.
 
Method Summary
 void addProperties(PropertiesBag options)
          Add new properties to this bag.
 boolean exists(java.lang.String key)
          Returns true if an option defined by a 'key' is present and has a non-empty value.
 java.lang.String format(int indent)
          As toString() but with indentations.
 boolean found(java.lang.String key, java.lang.String value)
          Returns true if an option indicated by 'key' is found within this bag AND is equal to a given value.
 int getInt(java.lang.String key)
          Return an integer value of the option indicated by 'key'.
 java.lang.String getStr(java.lang.String key)
          Return a string value of the option indicated by 'key'.
 boolean is(java.lang.String key)
          Returns true if an option defined by a 'key' is present and has a true value.
 boolean is(java.lang.String key, int serNo)
          Returns true if an option defined by a 'key' is present and has a true value.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertiesBag

public PropertiesBag()
An empty constructor.


PropertiesBag

public PropertiesBag(java.lang.String[] props)
Create a bag initialized with 'props'.


PropertiesBag

public PropertiesBag(java.lang.String propName,
                     java.lang.String propValue)
A convenient constructor for creating a bag with exactly one property.

Method Detail

addProperties

public void addProperties(PropertiesBag options)
Add new properties to this bag.


is

public boolean is(java.lang.String key)
Returns true if an option defined by a 'key' is present and has a true value. Used for elements of type String and Boolean.


is

public boolean is(java.lang.String key,
                  int serNo)
Returns true if an option defined by a 'key' is present and has a true value. Used for elements of type String and Boolean. The search key is extended by 'serNo' at its end (but only if serNo > 0). If the extended key was not found, a normal (plain) key is tried.

For example, you can look for 'debug1' by calling is ('debug', 1).


exists

public boolean exists(java.lang.String key)
Returns true if an option defined by a 'key' is present and has a non-empty value. It makes mostly sense for type String.


found

public boolean found(java.lang.String key,
                     java.lang.String value)
Returns true if an option indicated by 'key' is found within this bag AND is equal to a given value. Used for element of type String.


getStr

public java.lang.String getStr(java.lang.String key)
Return a string value of the option indicated by 'key'. Return an empty string if 'key' was not found. Used for element of type Integer and String.


getInt

public int getInt(java.lang.String key)
Return an integer value of the option indicated by 'key'. Return -1 if 'key' was not found. Return 0 if the element contains non-numeric value. Used for element of type Integer and String.


format

public java.lang.String format(int indent)
As toString() but with indentations.


Version: ${maven.project.version}

Submit a bug or feature
Generated: Tue Jun 14 15:18:14 AST 2011