Java Doc for AbstractConfiguration.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) 


java.lang.Object
   org.apache.commons.configuration.event.EventSource
      org.apache.commons.configuration.AbstractConfiguration

All known Subclasses:   org.apache.commons.configuration.DatabaseConfiguration,  org.apache.commons.configuration.web.BaseWebConfiguration,  org.apache.commons.configuration.JNDIConfiguration,  org.apache.commons.configuration.DataConfiguration,  org.apache.commons.configuration.HierarchicalConfiguration,  org.apache.commons.configuration.CompositeConfiguration,  org.apache.commons.configuration.NonCloneableConfiguration,  org.apache.commons.configuration.SubsetConfiguration,  org.apache.commons.configuration.MapConfiguration,  org.apache.commons.configuration.BaseConfiguration,
AbstractConfiguration
abstract public class AbstractConfiguration extends EventSource implements Configuration(Code)

Abstract configuration class. Provides basic functionality but does not store any data.

If you want to write your own Configuration class then you should implement only abstract methods from this class. A lot of functionality needed by typical implementations of the Configuration interface is already provided by this base class. Following is a list of feauters implemented here:

  • Data conversion support. The various data types required by the Configuration interface are already handled by this base class. A concrete sub class only needs to provide a generic getProperty() method.
  • Support for variable interpolation. Property values containing special variable tokens (like ${var}) will be replaced by their corresponding values.
  • Support for string lists. The values of properties to be added to this configuration are checked whether they contain a list delimiter character. If this is the case and if list splitting is enabled, the string is splitted and multiple values are added for this property. (With the setListDelimiter() method the delimiter character can be specified; per default a comma is used. The setDelimiterParsingDisabled() method can be used to disable list splitting completely.)
  • Allows to specify how missing properties are treated. Per default the get methods returning an object will return null if the searched property key is not found (and no default value is provided). With the setThrowExceptionOnMissing() method this behavior can be changed to throw an exception when a requested property cannot be found.
  • Basic event support. Whenever this configuration is modified registered event listeners are notified. Refer to the various EVENT_XXX constants to get an impression about which event types are supported.


author:
   Konstantin Shaposhnikov
author:
   Oliver Heger
author:
   Henning P. Schmiedehausen
version:
   $Id: AbstractConfiguration.java,v 1.29 2004/12/02 22:05:52 ebourg
version:
   Exp $


Field Summary
final protected static  StringEND_TOKEN
    
final public static  intEVENT_ADD_PROPERTY
     Constant for the add property event type.
final public static  intEVENT_CLEAR
     Constant for the clear configuration event type.
final public static  intEVENT_CLEAR_PROPERTY
     Constant for the clear property event type.
final public static  intEVENT_READ_PROPERTY
     Constant for the get property event type.
final public static  intEVENT_SET_PROPERTY
     Constant for the set property event type.
final protected static  StringSTART_TOKEN
    

Constructor Summary
public  AbstractConfiguration()
     Creates a new instance of AbstractConfiguration.

Method Summary
public  voidaddErrorLogListener()
     Adds a special org.apache.commons.configuration.event.ConfigurationErrorListener object to this configuration that will log all internal errors.
public  voidaddProperty(String key, Object value)
    
abstract protected  voidaddPropertyDirect(String key, Object value)
     Adds a key/value pair to the Configuration.
public  voidclear()
    
public  voidclearProperty(String key)
     Removes the specified property from this configuration.
protected  voidclearPropertyDirect(String key)
     Removes the specified property from this configuration.
abstract public  booleancontainsKey(String key)
    
protected  ConfigurationInterpolatorcreateInterpolator()
     Creates the interpolator object that is responsible for variable interpolation.
public  BigDecimalgetBigDecimal(String key)
    
public  BigDecimalgetBigDecimal(String key, BigDecimal defaultValue)
    
public  BigIntegergetBigInteger(String key)
    
public  BigIntegergetBigInteger(String key, BigInteger defaultValue)
    
public  booleangetBoolean(String key)
    
public  booleangetBoolean(String key, boolean defaultValue)
    
public  BooleangetBoolean(String key, Boolean defaultValue)
     Obtains the value of the specified key and tries to convert it into a Boolean object.
public  bytegetByte(String key)
    
public  bytegetByte(String key, byte defaultValue)
    
public  BytegetByte(String key, Byte defaultValue)
    
public static  chargetDefaultListDelimiter()
     Retrieve the current delimiter.
public static  chargetDelimiter()
     Returns the default list delimiter.
public  doublegetDouble(String key)
    
public  doublegetDouble(String key, double defaultValue)
    
public  DoublegetDouble(String key, Double defaultValue)
    
public  floatgetFloat(String key)
    
public  floatgetFloat(String key, float defaultValue)
    
public  FloatgetFloat(String key, Float defaultValue)
    
public  intgetInt(String key)
    
public  intgetInt(String key, int defaultValue)
    
public  IntegergetInteger(String key, Integer defaultValue)
    
public  ConfigurationInterpolatorgetInterpolator()
     Returns the ConfigurationInterpolator object that manages the lookup objects for resolving variables.
abstract public  IteratorgetKeys()
    
public  IteratorgetKeys(String prefix)
    
public  ListgetList(String key)
    
public  ListgetList(String key, List defaultValue)
    
public  chargetListDelimiter()
     Retrieve the delimiter for this configuration.
public  LoggetLogger()
     Returns the logger used by this configuration object.
public  longgetLong(String key)
    
public  longgetLong(String key, long defaultValue)
    
public  LonggetLong(String key, Long defaultValue)
    
public  PropertiesgetProperties(String key)
    
public  PropertiesgetProperties(String key, Properties defaults)
     Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaults - Any default values for the returnedProperties object.
public  shortgetShort(String key)
    
public  shortgetShort(String key, short defaultValue)
    
public  ShortgetShort(String key, Short defaultValue)
    
public  StringgetString(String key)
    
public  StringgetString(String key, String defaultValue)
    
public  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. If a property is added to a configuration, it is checked whether it contains multiple values.
public synchronized  StrSubstitutorgetSubstitutor()
     Returns the object that is responsible for variable interpolation.
protected  Stringinterpolate(String base)
    
protected  Objectinterpolate(Object value)
     Returns the interpolated value.
protected  StringinterpolateHelper(String base, List priorVariables)
     Recursive handler for multple levels of interpolation. When called the first time, priorVariables should be null.
Parameters:
  base - string with the ${key} variables
Parameters:
  priorVariables - serves two purposes: to allow checking for loops,and creating a meaningful exception message should a loop occur.
public  booleanisDelimiterParsingDisabled()
     Determine if this configuration is using delimiters when parsing property values to convert them to lists of values.
abstract public  booleanisEmpty()
    
public  booleanisThrowExceptionOnMissing()
     Returns true if missing values throw Exceptions.
protected  ObjectresolveContainerStore(String key)
     Returns an object from the store described by the key.
public static  voidsetDefaultListDelimiter(char delimiter)
     For configurations extending AbstractConfiguration, allow them to change the listDelimiter from the default comma (",").
public static  voidsetDelimiter(char delimiter)
     Sets the default list delimiter.
public  voidsetDelimiterParsingDisabled(boolean delimiterParsingDisabled)
     Set whether this configuration should use delimiters when parsing property values to convert them to lists of values.
public  voidsetListDelimiter(char listDelimiter)
     Change the list delimiter for this configuration. Note: this change will only be effective for new parsings.
public  voidsetLogger(Log log)
     Allows to set the logger to be used by this configuration object.
public  voidsetProperty(String key, Object value)
    
public  voidsetThrowExceptionOnMissing(boolean throwExceptionOnMissing)
     Allows to set the throwExceptionOnMissing flag.
public  Configurationsubset(String prefix)
    

Field Detail
END_TOKEN
final protected static String END_TOKEN(Code)
end token



EVENT_ADD_PROPERTY
final public static int EVENT_ADD_PROPERTY(Code)
Constant for the add property event type.
since:
   1.3



EVENT_CLEAR
final public static int EVENT_CLEAR(Code)
Constant for the clear configuration event type.
since:
   1.3



EVENT_CLEAR_PROPERTY
final public static int EVENT_CLEAR_PROPERTY(Code)
Constant for the clear property event type.
since:
   1.3



EVENT_READ_PROPERTY
final public static int EVENT_READ_PROPERTY(Code)
Constant for the get property event type. This event type is used for error events.
since:
   1.4



EVENT_SET_PROPERTY
final public static int EVENT_SET_PROPERTY(Code)
Constant for the set property event type.
since:
   1.3



START_TOKEN
final protected static String START_TOKEN(Code)
start token




Constructor Detail
AbstractConfiguration
public AbstractConfiguration()(Code)
Creates a new instance of AbstractConfiguration.




Method Detail
addErrorLogListener
public void addErrorLogListener()(Code)
Adds a special org.apache.commons.configuration.event.ConfigurationErrorListener object to this configuration that will log all internal errors. This method is intended to be used by certain derived classes, for which it is known that they can fail on property access (e.g. DatabaseConfiguration).
since:
   1.4



addProperty
public void addProperty(String key, Object value)(Code)



addPropertyDirect
abstract protected void addPropertyDirect(String key, Object value)(Code)
Adds a key/value pair to the Configuration. Override this method to provide write acces to underlying Configuration store.
Parameters:
  key - key to use for mapping
Parameters:
  value - object to store



clear
public void clear()(Code)



clearProperty
public void clearProperty(String key)(Code)
Removes the specified property from this configuration. This implementation performs some preparations and then delegates to clearPropertyDirect(), which will do the real work.
Parameters:
  key - the key to be removed



clearPropertyDirect
protected void clearPropertyDirect(String key)(Code)
Removes the specified property from this configuration. This method is called by clearProperty() after it has done some preparations. It should be overriden in sub classes. This base implementation is just left empty.
Parameters:
  key - the key to be removed



containsKey
abstract public boolean containsKey(String key)(Code)



createInterpolator
protected ConfigurationInterpolator createInterpolator()(Code)
Creates the interpolator object that is responsible for variable interpolation. This method is invoked on first access of the interpolation features. It creates a new instance of ConfigurationInterpolator and sets the default lookup object to an implementation that queries this configuration. the newly created interpolator object
since:
   1.4



getBigDecimal
public BigDecimal getBigDecimal(String key)(Code)

See Also:   AbstractConfiguration.setThrowExceptionOnMissing(boolean)



getBigDecimal
public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)(Code)



getBigInteger
public BigInteger getBigInteger(String key)(Code)

See Also:   AbstractConfiguration.setThrowExceptionOnMissing(boolean)



getBigInteger
public BigInteger getBigInteger(String key, BigInteger defaultValue)(Code)



getBoolean
public boolean getBoolean(String key)(Code)

See Also:   PropertyConverter.toBoolean(Object)



getBoolean
public boolean getBoolean(String key, boolean defaultValue)(Code)

See Also:   PropertyConverter.toBoolean(Object)



getBoolean
public Boolean getBoolean(String key, Boolean defaultValue)(Code)
Obtains the value of the specified key and tries to convert it into a Boolean object. If the property has no value, the passed in default value will be used.
Parameters:
  key - the key of the property
Parameters:
  defaultValue - the default value the value of this key converted to a Boolean
throws:
  ConversionException - if the value cannot be converted to aBoolean
See Also:   PropertyConverter.toBoolean(Object)



getByte
public byte getByte(String key)(Code)



getByte
public byte getByte(String key, byte defaultValue)(Code)



getByte
public Byte getByte(String key, Byte defaultValue)(Code)



getDefaultListDelimiter
public static char getDefaultListDelimiter()(Code)
Retrieve the current delimiter. By default this is a comma (","). The delimiter in use



getDelimiter
public static char getDelimiter()(Code)
Returns the default list delimiter. the default list delimiter



getDouble
public double getDouble(String key)(Code)



getDouble
public double getDouble(String key, double defaultValue)(Code)



getDouble
public Double getDouble(String key, Double defaultValue)(Code)



getFloat
public float getFloat(String key)(Code)



getFloat
public float getFloat(String key, float defaultValue)(Code)



getFloat
public Float getFloat(String key, Float defaultValue)(Code)



getInt
public int getInt(String key)(Code)



getInt
public int getInt(String key, int defaultValue)(Code)



getInteger
public Integer getInteger(String key, Integer defaultValue)(Code)



getInterpolator
public ConfigurationInterpolator getInterpolator()(Code)
Returns the ConfigurationInterpolator object that manages the lookup objects for resolving variables. Note: If this object is manipulated (e.g. new lookup objects added), synchronisation has to be manually ensured. Because ConfigurationInterpolator is not thread-safe concurrent access to properties of this configuration instance (which causes the interpolator to be invoked) may cause race conditions. the ConfigurationInterpolator associated with thisconfiguration
since:
   1.4



getKeys
abstract public Iterator getKeys()(Code)



getKeys
public Iterator getKeys(String prefix)(Code)



getList
public List getList(String key)(Code)

See Also:   AbstractConfiguration.getStringArray(String)



getList
public List getList(String key, List defaultValue)(Code)



getListDelimiter
public char getListDelimiter()(Code)
Retrieve the delimiter for this configuration. The default is the value of defaultListDelimiter. The listDelimiter in use



getLogger
public Log getLogger()(Code)
Returns the logger used by this configuration object. the logger
since:
   1.4



getLong
public long getLong(String key)(Code)



getLong
public long getLong(String key, long defaultValue)(Code)



getLong
public Long getLong(String key, Long defaultValue)(Code)



getProperties
public Properties getProperties(String key)(Code)



getProperties
public Properties getProperties(String key, Properties defaults)(Code)
Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaults - Any default values for the returnedProperties object. Ignored if null. The associated properties if key is found.
throws:
  ConversionException - is thrown if the key maps to an object thatis not a String/List of Strings.
throws:
  IllegalArgumentException - if one of the tokens is malformed (doesnot contain an equals sign).



getShort
public short getShort(String key)(Code)



getShort
public short getShort(String key, short defaultValue)(Code)



getShort
public Short getShort(String key, Short defaultValue)(Code)



getString
public String getString(String key)(Code)

See Also:   AbstractConfiguration.setThrowExceptionOnMissing(boolean)



getString
public String getString(String key, String defaultValue)(Code)



getStringArray
public 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. If a property is added to a configuration, it is checked whether it contains multiple values. This is obvious if the added object is a list or an array. For strings it is checked whether the string contains the list delimiter character that can be specified using the setListDelimiter() method. If this is the case, the string is splitted at these positions resulting in a property with multiple values.
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.
See Also:   AbstractConfiguration.setListDelimiter(char)
See Also:   AbstractConfiguration.setDelimiterParsingDisabled(boolean)



getSubstitutor
public synchronized StrSubstitutor getSubstitutor()(Code)
Returns the object that is responsible for variable interpolation. the object responsible for variable interpolation
since:
   1.4



interpolate
protected String interpolate(String base)(Code)
interpolate key names to handle ${key} stuff
Parameters:
  base - string to interpolate returns the key name with the ${key} substituted



interpolate
protected Object interpolate(Object value)(Code)
Returns the interpolated value. Non String values are returned without change.
Parameters:
  value - the value to interpolate returns the value with variables substituted



interpolateHelper
protected String interpolateHelper(String base, List priorVariables)(Code)
Recursive handler for multple levels of interpolation. When called the first time, priorVariables should be null.
Parameters:
  base - string with the ${key} variables
Parameters:
  priorVariables - serves two purposes: to allow checking for loops,and creating a meaningful exception message should a loop occur. It's0'th element will be set to the value of base from the first call. Allsubsequent interpolated variables are added afterward. the string with the interpolation taken care ofPropertyConverter



isDelimiterParsingDisabled
public boolean isDelimiterParsingDisabled()(Code)
Determine if this configuration is using delimiters when parsing property values to convert them to lists of values. Defaults to false true if delimiters are not being used



isEmpty
abstract public boolean isEmpty()(Code)



isThrowExceptionOnMissing
public boolean isThrowExceptionOnMissing()(Code)
Returns true if missing values throw Exceptions. true if missing values throw Exceptions



resolveContainerStore
protected Object resolveContainerStore(String key)(Code)
Returns an object from the store described by the key. If the value is a List object, replace it with the first object in the list.
Parameters:
  key - The property key. value Value, transparently resolving a possible List dependency.



setDefaultListDelimiter
public static void setDefaultListDelimiter(char delimiter)(Code)
For configurations extending AbstractConfiguration, allow them to change the listDelimiter from the default comma (","). This value will be used only when creating new configurations. Those already created will not be affected by this change
Parameters:
  delimiter - The new listDelimiter



setDelimiter
public static void setDelimiter(char delimiter)(Code)
Sets the default list delimiter.
Parameters:
  delimiter - the delimiter character



setDelimiterParsingDisabled
public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)(Code)
Set whether this configuration should use delimiters when parsing property values to convert them to lists of values. By default delimiter parsing is enabled Note: this change will only be effective for new parsings. If you want it to take effect for all loaded properties use the no arg constructor and call this method before setting source.
Parameters:
  delimiterParsingDisabled - a flag whether delimiter parsing shouldbe disabled



setListDelimiter
public void setListDelimiter(char listDelimiter)(Code)
Change the list delimiter for this configuration. Note: this change will only be effective for new parsings. If you want it to take effect for all loaded properties use the no arg constructor and call this method before setting the source.
Parameters:
  listDelimiter - The new listDelimiter



setLogger
public void setLogger(Log log)(Code)
Allows to set the logger to be used by this configuration object. This method makes it possible for clients to exactly control logging behavior. Per default a logger is set that will ignore all log messages. Derived classes that want to enable logging should call this method during their initialization with the logger to be used.
Parameters:
  log - the new logger
since:
   1.4



setProperty
public void setProperty(String key, Object value)(Code)



setThrowExceptionOnMissing
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)(Code)
Allows to set the throwExceptionOnMissing flag. This flag controls the behavior of property getter methods that return objects if the requested property is missing. If the flag is set to false (which is the default value), these methods will return null. If set to true, they will throw a NoSuchElementException exception. Note that getter methods for primitive data types are not affected by this flag.
Parameters:
  throwExceptionOnMissing - The new value for the property



subset
public Configuration subset(String prefix)(Code)



Methods inherited from org.apache.commons.configuration.event.EventSource
public void addConfigurationListener(ConfigurationListener l)(Code)(Java Doc)
public void addErrorListener(ConfigurationErrorListener l)(Code)(Java Doc)
public void clearConfigurationListeners()(Code)(Java Doc)
public void clearErrorListeners()(Code)(Java Doc)
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
protected ConfigurationErrorEvent createErrorEvent(int type, String propName, Object propValue, Throwable ex)(Code)(Java Doc)
protected ConfigurationEvent createEvent(int type, String propName, Object propValue, boolean before)(Code)(Java Doc)
protected void fireError(int type, String propName, Object propValue, Throwable ex)(Code)(Java Doc)
protected void fireEvent(int type, String propName, Object propValue, boolean before)(Code)(Java Doc)
public Collection getConfigurationListeners()(Code)(Java Doc)
public Collection getErrorListeners()(Code)(Java Doc)
public boolean isDetailEvents()(Code)(Java Doc)
public boolean removeConfigurationListener(ConfigurationListener l)(Code)(Java Doc)
public boolean removeErrorListener(ConfigurationErrorListener l)(Code)(Java Doc)
public void setDetailEvents(boolean enable)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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