Java Doc for Configuration.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.configuration.Configuration

All known Subclasses:   org.apache.commons.configuration.AbstractConfiguration,
Configuration
public interface Configuration (Code)

The main Configuration interface.

This interface allows accessing and manipulating a configuration object. The major part of the methods defined in this interface deals with accessing properties of various data types. There is a generic getProperty() method, which returns the value of the queried property in its raw data type. Other getter methods try to convert this raw data type into a specific data type. If this fails, a ConversionException will be thrown.

For most of the property getter methods an overloaded version exists that allows to specify a default value, which will be returned if the queried property cannot be found in the configuration. The behavior of the methods that do not take a default value in case of a missing property is not defined by this interface and depends on a concrete implementation. E.g. the AbstractConfiguration class, which is the base class of most configuration implementations provided by this package, per default returns null if a property is not found, but provides the org.apache.commons.configuration.AbstractConfiguration.setThrowExceptionOnMissing(boolean)setThrowExceptionOnMissing() method, with which it can be configured to throw a NoSuchElementException exception in that case. (Note that getter methods for primitive types in AbstractConfiguration always throw an exception for missing properties because there is no way of overloading the return value.)

With the addProperty() and setProperty() methods new properties can be added to a configuration or the values of properties can be changed. With clearProperty() a property can be removed. Other methods allow to iterate over the contained properties or to create a subset configuration.


author:
   Commons Configuration team
version:
   $Id: Configuration.java 449017 2006-09-22 17:27:00Z oheger $




Method Summary
 voidaddProperty(String key, Object value)
     Add a property to the configuration.
 voidclear()
     Remove all properties from the configuration.
 voidclearProperty(String key)
     Remove a property from the configuration.
 booleancontainsKey(String key)
     Check if the configuration contains the specified key.
 BigDecimalgetBigDecimal(String key)
     Get a BigDecimal associated with the given configuration key.
Parameters:
  key - The configuration key.
 BigDecimalgetBigDecimal(String key, BigDecimal defaultValue)
     Get a BigDecimal associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 BigIntegergetBigInteger(String key)
     Get a BigInteger associated with the given configuration key.
Parameters:
  key - The configuration key.
 BigIntegergetBigInteger(String key, BigInteger defaultValue)
     Get a BigInteger associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 booleangetBoolean(String key)
     Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
 booleangetBoolean(String key, boolean defaultValue)
     Get a boolean associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 BooleangetBoolean(String key, Boolean defaultValue)
     Get a Boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 bytegetByte(String key)
     Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
 bytegetByte(String key, byte defaultValue)
     Get a byte associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 BytegetByte(String key, Byte defaultValue)
     Get a Byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 doublegetDouble(String key)
     Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
 doublegetDouble(String key, double defaultValue)
     Get a double associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 DoublegetDouble(String key, Double defaultValue)
     Get a Double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 floatgetFloat(String key)
     Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
 floatgetFloat(String key, float defaultValue)
     Get a float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 FloatgetFloat(String key, Float defaultValue)
     Get a Float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 intgetInt(String key)
     Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
 intgetInt(String key, int defaultValue)
     Get a int associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 IntegergetInteger(String key, Integer defaultValue)
     Get an Integer associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 IteratorgetKeys(String prefix)
     Get the list of the keys contained in the configuration that match the specified prefix.
Parameters:
  prefix - The prefix to test against.
 IteratorgetKeys()
     Get the list of the keys contained in the configuration.
 ListgetList(String key)
     Get a List of strings associated with the given configuration key. If the key doesn't map to an existing object an empty List is returned.
Parameters:
  key - The configuration key.
 ListgetList(String key, List defaultValue)
     Get a List of strings associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 longgetLong(String key)
     Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
 longgetLong(String key, long defaultValue)
     Get a long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 LonggetLong(String key, Long defaultValue)
     Get a Long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 PropertiesgetProperties(String key)
     Get a list of properties associated with the given configuration key. This method expects the given key to have an arbitrary number of String values, each of which is of the form key=value.
 ObjectgetProperty(String key)
     Gets a property from the configuration.
 shortgetShort(String key)
     Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
 shortgetShort(String key, short defaultValue)
     Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 ShortgetShort(String key, Short defaultValue)
     Get a Short associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 StringgetString(String key)
     Get a string associated with the given configuration key.
Parameters:
  key - The configuration key.
 StringgetString(String key, String defaultValue)
     Get a string associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
 String[]getStringArray(String key)
     Get an array of strings associated with the given configuration key. If the key doesn't map to an existing object an empty array is returned
Parameters:
  key - The configuration key.
 booleanisEmpty()
     Check if the configuration is empty.
 voidsetProperty(String key, Object value)
     Set a property, this will replace any previously set values.
 Configurationsubset(String prefix)
     Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix.



Method Detail
addProperty
void addProperty(String key, Object value)(Code)
Add a property to the configuration. If it already exists then the value stated here will be added to the configuration entry. For example, if the property:
resource.loader = file
is already present in the configuration and you call
addProperty("resource.loader", "classpath")
Then you will end up with a List like the following:
["file", "classpath"]

Parameters:
  key - The key to add the property to.
Parameters:
  value - The value to add.



clear
void clear()(Code)
Remove all properties from the configuration.



clearProperty
void clearProperty(String key)(Code)
Remove a property from the configuration.
Parameters:
  key - the key to remove along with corresponding value.



containsKey
boolean containsKey(String key)(Code)
Check if the configuration contains the specified key.
Parameters:
  key - the key whose presence in this configuration is to be tested true if the configuration contains a value for thiskey, false otherwise



getBigDecimal
BigDecimal getBigDecimal(String key)(Code)
Get a BigDecimal associated with the given configuration key.
Parameters:
  key - The configuration key. The associated BigDecimal if key is found and has valid format



getBigDecimal
BigDecimal getBigDecimal(String key, BigDecimal defaultValue)(Code)
Get a BigDecimal associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated BigDecimal if key is found and has validformat, default value otherwise.



getBigInteger
BigInteger getBigInteger(String key)(Code)
Get a BigInteger associated with the given configuration key.
Parameters:
  key - The configuration key. The associated BigInteger if key is found and has valid format



getBigInteger
BigInteger getBigInteger(String key, BigInteger defaultValue)(Code)
Get a BigInteger associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated BigInteger if key is found and has validformat, default value otherwise.



getBoolean
boolean getBoolean(String key)(Code)
Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key. The associated boolean.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Boolean.



getBoolean
boolean getBoolean(String key, boolean defaultValue)(Code)
Get a boolean associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated boolean.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Boolean.



getBoolean
Boolean getBoolean(String key, Boolean defaultValue)(Code)
Get a Boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated boolean if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Boolean.



getByte
byte getByte(String key)(Code)
Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key. The associated byte.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Byte.



getByte
byte getByte(String key, byte defaultValue)(Code)
Get a byte associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated byte.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Byte.



getByte
Byte getByte(String key, Byte defaultValue)(Code)
Get a Byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated byte if key is found and has valid format, defaultvalue otherwise.
throws:
  ConversionException - is thrown if the key maps to an object thatis not a Byte.



getDouble
double getDouble(String key)(Code)
Get a double associated with the given configuration key.
Parameters:
  key - The configuration key. The associated double.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Double.



getDouble
double getDouble(String key, double defaultValue)(Code)
Get a double associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated double.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Double.



getDouble
Double getDouble(String key, Double defaultValue)(Code)
Get a Double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated double if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Double.



getFloat
float getFloat(String key)(Code)
Get a float associated with the given configuration key.
Parameters:
  key - The configuration key. The associated float.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Float.



getFloat
float getFloat(String key, float defaultValue)(Code)
Get a float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated float.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Float.



getFloat
Float getFloat(String key, Float defaultValue)(Code)
Get a Float associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated float if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Float.



getInt
int getInt(String key)(Code)
Get a int associated with the given configuration key.
Parameters:
  key - The configuration key. The associated int.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Integer.



getInt
int getInt(String key, int defaultValue)(Code)
Get a int associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated int.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Integer.



getInteger
Integer getInteger(String key, Integer defaultValue)(Code)
Get an Integer associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated int if key is found and has valid format, defaultvalue otherwise.
throws:
  ConversionException - is thrown if the key maps to an object thatis not a Integer.



getKeys
Iterator getKeys(String prefix)(Code)
Get the list of the keys contained in the configuration that match the specified prefix.
Parameters:
  prefix - The prefix to test against. An Iterator of keys that match the prefix.
See Also:   Configuration.getKeys()



getKeys
Iterator getKeys()(Code)
Get the list of the keys contained in the configuration. The returned iterator can be used to obtain all defined keys. Note that the exact behavior of the iterator's remove() method is specific to a concrete implementation. It may remove the corresponding property from the configuration, but this is not guaranteed. In any case it is no replacement for calling Configuration.clearProperty(String) for this property. So it is highly recommended to avoid using the iterator's remove() method. An Iterator.



getList
List getList(String key)(Code)
Get a List of strings associated with the given configuration key. If the key doesn't map to an existing object an empty List is returned.
Parameters:
  key - The configuration key. The associated List.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a List.



getList
List getList(String key, List defaultValue)(Code)
Get a List of strings associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated List of strings.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a List.



getLong
long getLong(String key)(Code)
Get a long associated with the given configuration key.
Parameters:
  key - The configuration key. The associated long.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Long.



getLong
long getLong(String key, long defaultValue)(Code)
Get a long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated long.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Long.



getLong
Long getLong(String key, Long defaultValue)(Code)
Get a Long associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated long if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Long.



getProperties
Properties getProperties(String key)(Code)
Get a list of properties associated with the given configuration key. This method expects the given key to have an arbitrary number of String values, each of which is of the form key=value. These strings are splitted at the equals sign, and the key parts will become keys of the returned Properties object, the value parts become values.
Parameters:
  key - The configuration key. The associated properties if key is found.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a String/List.
throws:
  IllegalArgumentException - if one of the tokens ismalformed (does not contain an equals sign).



getProperty
Object getProperty(String key)(Code)
Gets a property from the configuration. This is the most basic get method for retrieving values of properties. In a typical implementation of the Configuration interface the other get methods (that return specific data types) will internally make use of this method. On this level variable substitution is not yet performed. The returned object is an internal representation of the property value for the passed in key. It is owned by the Configuration object. So a caller should not modify this object. It cannot be guaranteed that this object will stay constant over time (i.e. further update operations on the configuration may change its internal state).
Parameters:
  key - property to retrieve the value to which this configuration maps the specified key, ornull if the configuration contains no mapping for this key.



getShort
short getShort(String key)(Code)
Get a short associated with the given configuration key.
Parameters:
  key - The configuration key. The associated short.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Short.



getShort
short getShort(String key, short defaultValue)(Code)
Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated short.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Short.



getShort
Short getShort(String key, Short defaultValue)(Code)
Get a Short associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated short if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a Short.



getString
String getString(String key)(Code)
Get a string associated with the given configuration key.
Parameters:
  key - The configuration key. The associated string.
throws:
  ConversionException - is thrown if the key maps to an object thatis not a String.



getString
String getString(String key, String defaultValue)(Code)
Get a string associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated string if key is found and has validformat, default value otherwise.
throws:
  ConversionException - is thrown if the key maps to an object thatis not a String.



getStringArray
String[] getStringArray(String key)(Code)
Get an array of strings associated with the given configuration key. If the key doesn't map to an existing object an empty array is returned
Parameters:
  key - The configuration key. The associated string array if key is found.
throws:
  ConversionException - is thrown if the key maps to anobject that is not a String/List of Strings.



isEmpty
boolean isEmpty()(Code)
Check if the configuration is empty. true if the configuration contains no property,false otherwise.



setProperty
void setProperty(String key, Object value)(Code)
Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).
Parameters:
  key - The key of the property to change
Parameters:
  value - The new value



subset
Configuration subset(String prefix)(Code)
Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix. The prefix is removed from the keys in the subset. For example, if the configuration contains the following properties:
 prefix.number = 1
 prefix.string = Apache
 prefixed.foo = bar
 prefix = Jakarta
the Configuration returned by subset("prefix") will contain the properties:
 number = 1
 string = Apache
 = Jakarta
(The key for the value "Jakarta" is an empty string)

Since the subset is a decorator and not a modified copy of the initial Configuration, any change made to the subset is available to the Configuration, and reciprocally.
Parameters:
  prefix - The prefix used to select the properties. a subset configuration
See Also:   SubsetConfiguration




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.